Hi Steve, thanks for your reply; the theme developer (Elegant Themes) wasn’t very helpful. I’ve almost done it with the code below, which allows me to choose the category from within my slider module but i’m getting this within the slider:
“No Results Found
The page you requested could not be found. Try refining your search, or use the navigation above to locate the post.”
This is the code to include the category:
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if( is_category() ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('nav_menu_item', 'post', 'country_walks'); // don't forget nav_menu_item to allow menus to work!
$query->set('post_type',$post_type);
return $query;
}
}
Is adding a taxonomies essential to the custom post type as i’ve not done this..
Here’s my post type code:
function cptui_register_my_cpts_country_walks() {
/**
* Post Type: Country Walks.
*/
$labels = [
"name" => __( "Country Walks", "custom-post-type-ui" ),
"singular_name" => __( "Walks", "custom-post-type-ui" ),
"view_item" => __( "View Page", "custom-post-type-ui" ),
"view_items" => __( "View Walks", "custom-post-type-ui" ),
];
$args = [
"label" => __( "Country Walks", "custom-post-type-ui" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => true,
"rest_base" => "",
"rest_controller_class" => "WP_REST_Posts_Controller",
"has_archive" => false,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"delete_with_user" => false,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => [ "slug" => "country_walks", "with_front" => true ],
"query_var" => true,
"supports" => [ "title", "editor", "thumbnail", "excerpt", "custom-fields", "page-attributes", "post-formats" ],
"taxonomies" => [ "category" ],
];
register_post_type( "country_walks", $args );
}
add_action( 'init', 'cptui_register_my_cpts_country_walks' );
-
This reply was modified 4 years, 10 months ago by Jackie Chan.
-
This reply was modified 4 years, 10 months ago by Jackie Chan.
-
This reply was modified 4 years, 10 months ago by Jackie Chan.
-
This reply was modified 4 years, 10 months ago by Jackie Chan.
-
This reply was modified 4 years, 10 months ago by Jackie Chan.