Custom post type as child of page

If you want your custom post type listed under a page you can add the permalink of the page to the rewrite slug like so: register_post_type(‘my_books’, array( ‘has_archive’ => false, // Stops domain.com/book becoming the cpt’s archive ‘rewrite’ => array(‘slug’ => ‘book’) )); You need to visit Settings->Permalinks after making any changes to permalinks to … Read more

Custom post type clean shortlink

Yes this is correct. You can choose custom permalink the way you want. But it is limited to these official tags only. And %post_id% is one of those tags so you can use it. Just a note here you need to end the custom structure with post ID or name as codex says Make sure … Read more

Add a filter to get_comments_link()

Modifications of the core code are not recommended. Note that the core get_comments_link() function considers two cases of $hash: $hash = get_comments_number( $post_id ) ? ‘#comments’ : ‘#respond’; Also note the second input argument is $post_id. Here’s your modified example: add_filter( ‘get_comments_link’, function( $link, $post_id ) { $hash = get_comments_number( $post_id ) ? ‘#mycomments’ : … Read more