admin管理员组文章数量:1122846
I'm aware this may be incredibly simple, but I've just never happened to need to know this until now.
I am using custom query var and rewrite rule as follows:
$queryVars[] = 'my_query_var';
add_rewrite_rule('my-custom-page/?','index.php?my_query_var=my-custom-page','top');
I am using the Newspaper theme. No child theme.
When all is activated, permalinks flushed, and I load /, I am served with the standard Newspaper page.php template, which shows all posts(?) like an archive page.
I have my own tried and tested custom code that recognises when the user has navigated to the above link. It successfully processes all code, and adds to the current template at a location of my choosing. When I activate my custom query var and rewite rule, the current template changes to the above mentioned archive type of page.
How can I change this back/stop this/manipulate the template used, correctly?
Many thanks =)
I'm aware this may be incredibly simple, but I've just never happened to need to know this until now.
I am using custom query var and rewrite rule as follows:
$queryVars[] = 'my_query_var';
add_rewrite_rule('my-custom-page/?','index.php?my_query_var=my-custom-page','top');
I am using the Newspaper theme. No child theme.
When all is activated, permalinks flushed, and I load https://myurl.com/my-custom-page/, I am served with the standard Newspaper page.php template, which shows all posts(?) like an archive page.
I have my own tried and tested custom code that recognises when the user has navigated to the above link. It successfully processes all code, and adds to the current template at a location of my choosing. When I activate my custom query var and rewite rule, the current template changes to the above mentioned archive type of page.
How can I change this back/stop this/manipulate the template used, correctly?
Many thanks =)
Share Improve this question edited May 20, 2024 at 11:25 Tom J Nowell♦ 60.7k7 gold badges77 silver badges147 bronze badges asked May 20, 2024 at 10:53 user242851user242851 1 3 |1 Answer
Reset to default 0Normally, my-custom-page/
would be rewritten to index.php?page_id=2
(or whatever the ID of that particular page is). Your rewrite is omitting the page_id
var, which is why you're getting the blog index instead of your page.
本文标签: pluginsNewspaper themecustom query varsamp custom rewrite rules
版权声明:本文标题:plugins - Newspaper theme, custom query vars, & custom rewrite rules 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736306587a1933009.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
init
hook it probably won't work. Does your non-pretty URL give you what you expected? You mentioned you have code that recognises this and works but have not shared it, and no filenames or template names are mentioned. Can you edit this information into your question? – Tom J Nowell ♦ Commented May 20, 2024 at 11:26Edit
link underneath the question tags. Avoid referring to things genericallye.g. don't say "the template", give it a name even if it's an example – Tom J Nowell ♦ Commented May 20, 2024 at 12:41