Show Custom Post Type by Author

You will need to filter ‘author_link’ to conditionally add the parameter that can be used to add the custom post type into the query for the author’s posts. add_filter( ‘author_link’, ‘myprefix_author_link’, 10, 3 ); function myprefix_author_link( $link, $author_id, $author_nicename ) { if ( is_singular( ‘myCPT’ ) || is_post_type_archive( ‘myCPT’ ) ) { $link = add_query_arg( … Read more

Display CPT taxonomies as an archive page

You’re describing the default behaviour. Based on your code, you will have the following URLs: https://www.url.com/blog/addresses/ The archive of all Articles. https://www.url.com/blog/city/tunis/ The archive of all Articles assigned to the Tunis City. https://www.url.com/blog/addresses/article-title/ The single Article. If any of these URLs are returning a 404, you likely just need to flush your permalinks. This needs … Read more

How to show term-specific post list, without posts associated with child terms?

As @Milo’s pointer said, this: Sadly, is normal WordPress behaviour. Can be suppressed using parse_tax_query and include_children set at 0… The code found in the answer at https://wordpress.stackexchange.com/a/202773/39300 Works for me… function taxonomy_archive_exclude_children($query){ $taxonomy_slugs = [‘product_category’, ‘application_category’]; if($query->is_main_query() && is_tax($taxonomy_slugs)){ foreach($query->tax_query->queries as &$tax_query_item){ if(empty($taxonomy_slugs) || in_array($tax_query_item[‘taxonomy’], $taxonomy_slugs)){ $tax_query_item[‘include_children’] = 0; } } } } add_action(‘parse_tax_query’, … Read more

Order custom posts by taxonomy?

I believe you need a tax_query like the following from the Codex: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’ ) ) ); $query = new WP_Query( $args ); In your case that would look something like: $args = array( ‘post_type’ => ‘books’, ‘tax_query’ … Read more

How to remove/hide elements from the admin menu?

If you just want to hide the menu items, you can do it like shown below. Don’t forget about the entries inside the admin bar. Code: //hide in admin menu add_action( ‘admin_menu’, ‘wpse121406_hide_pages_comments_m’ ); function wpse121406_hide_pages_comments_m() { remove_menu_page(‘edit.php?post_type=page’); remove_menu_page( ‘edit-comments.php’ ); } //hide in admin bar add_action( ‘wp_before_admin_bar_render’, ‘wpse121406_hide_pages_comments_b’ ); function wpse121406_hide_pages_comments_b() { global $wp_admin_bar; … Read more