I want to create in my Wordpress website a dynamic page to show popular posts, and other stuff
I need to handle /popular request in a custom template file without creating a Wordpress page, and name the template file page-popular.php
I tried
add_action( 'init', 'rewrite_init' );
function rewrite_init()
{
add_rewrite_rule( 'popular/?', 'index.php?popular=true', 'top' );
}
Then I tried to check if the query string popular is set, I failed
If I've understood your question correctly: you don't want to create a new Page (via Pages in wp-admin), but you do want to use a custom page template file - is that correct?
In that case, this topic probably answers your question:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.