Routing dynamic numeric slug to custom template

The easiest way is to simply create a custom rewrite endpoint. This is a two-fer. It will create our actual permalink structure and our query var in one go. Do note that after creating the below you will need to resave permalinks: Settings -> Permalinks -> save button. /** * Create Careers Endpoint * * … Read more

Child page in custom post throws 404 page not found

It turns out the WordPress permalink structure works perfectly well for custom types, e.g. example.com/recipes/lunch/sandwich/. This works exactly as expected if you set ‘hierarchical’ => true. What I was originally trying to do was unnecessarily difficult to execute, and requires properly setting up a custom permalink structure to avoid 404 errors. I advise you stick … Read more

Custom post type routing with hierarchy

When you declare the custom post type, there is a parameter “rewrite” where you declare the slug for the post type. Change the slug to “media/videos”, and then visit your Settings > Permalinks page to update your rewrite rules. register_post_type( ‘videos’, array(‘labels’ => array(), ‘rewrite’ => array( ‘slug’ => ‘media/videos’, ‘with_front’ => false ) ) … Read more

.htaccess for wordpress in separate folder

Rather than change .htaccess, move the index.php up to root, open it, and change: require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ ); to: require( dirname( __FILE__ ) . ‘/wp/wp-blog-header.php’ ); In Settings, your WordPress address should be http://example.com/wp, and Site address should be http://example.com. This process is outlined in the Codex page Giving WordPress Its Own … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)