Categories filtering in new post
Categories filtering in new post
Categories filtering in new post
I think your problem is at the following lines: if ( get_query_var( ‘post_type’ ) ) $post_type = get_query_var( ‘post_type’ ); else $post_type=”job_listing”; Your post_type var will probably already being set, so you are calling some different post type (the one stored inside the query_vars array with the post_type key), which maybe does not have a … Read more
You will need to add your post types in an array. So your code should look like this ‘pages’ => array(‘post’, ‘sfwd-courses’, ‘sfwd-lessons’, ‘sfwd-topics’), You should also have a look at this tutorial that I find helpful as well
Define/declare new custom types with fields in plugin?
Configuring a meta query with multiple post types that have the same relationship on a single page
You’re setting arguments for the main query in your pre_get_posts action, and then overwriting that query in the template by calling query_posts (which you should never use). If you want to exclude categories, do that in the same pre_get_posts action: add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ ); function add_my_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ){ … Read more
OK, so you have few mistakes in there. field can be term_id or slug, but not id. tax_query should be array of arrays and not an array. So here is fixed code: function exclude_category( $query ) { if ( is_user_logged_in() && $query->is_main_query() ) { $taxquery = array( array( ‘taxonomy’ => ‘project-type’, ‘field’ => ‘term_id’, ‘terms’ … Read more
You have to use $paged variable like this : <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $posts = get_posts(array( ‘post_type’ => ‘product’, ‘taxonomy’ => $category->taxonomy, ‘term’ => $category->slug, ‘posts_per_page’ => 10, ‘paged’ => $paged ));
Is there any way to add a “custom field” to the CPT archive page?
Custom Theme With Custom Loops