Custom pages with plugin

When you visit a frontend page, WordPress will query the database and if your page does not exist in the database, that query is not needed and is just a waste of resources. Luckily, WordPress offers a way to handle frontend requests in a custom way. That is done thanks to the ‘do_parse_request’ filter. Returning … Read more

remove “index.php” from permalinks

Go to your WP-ADMIN–>Settings–>Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file. Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content, <?php phpinfo();?> Upload this file and browse via Browser. So you know which modules are … Read more

Mixing custom post type and taxonomy rewrite structures?

You can always override the template that will be called with the template_include or a related filter, but this might hide deeper problems with custom archives. As I understand it, you want to use the following structure: /glossary/ should be an archive page for all sumo-glossary-term posts /glossary/[letter]/ should be an archive page for posts … Read more

Custom Post Type URL Rewriting?

When you register the custom post type, you have to specify that the rewrite rule shouldn’t be prepended with the existing URL structure. In short, this means that this line in your register_post_type call: ‘rewrite’ => array(‘slug’ => ‘projects’), should turn into this: ‘rewrite’ => array(‘slug’ => ‘projects’,’with_front’ => false), For more info, check out … Read more

How do you create a “virtual” page in WordPress

There are two types of rewrite rules in WordPress: internal rules (stored in the database and parsed by WP::parse_request()), and external rules (stored in .htaccess and parsed by Apache). You can choose either way, depending on how much of WordPress you need in your called file. External Rules: The external rule is the easiest to … Read more

How to create custom URL routes?

Add this to your theme’s functions.php, or put it in a plugin. add_action( ‘init’, ‘wpse26388_rewrites_init’ ); function wpse26388_rewrites_init(){ add_rewrite_rule( ‘properties/([0-9]+)/?$’, ‘index.php?pagename=properties&property_id=$matches[1]’, ‘top’ ); } add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘property_id’; return $query_vars; } This adds a rewrite rule which directs requests to /properties/ with any combination of numbers following to … Read more