How do I Query 2 Custom Post Types?

Firstly, do not use query_post(), there almost never is reason to do so – take a look at When to use WP_query(), query_posts() and pre_get_posts. Secondly, read the documentation about the things you want to achieve, here WP_Query – Type Parameters. Thirdly, take a close look at what you’re writing/copying there might be a syntax … Read more

Page-CPT.php redirects to archive or single.php

You’re missing this in your code and the names of your template hierachy seems to be wrong. page-cpt.php relates to a page template and not a CPT archive. ‘rewrite’ => array( ‘slug’ => ‘top-ten-list’, ‘with_front’ => false ), Assuming you use the slug top-ten-list You should name your archive template archive-top-ten-list.php You should name your … Read more

Limit search field to just search a custom post type with custom fields

post_title isn’t a valid argument to WP_Query. If you dump the SQL you will see that it is ignored: string(189) “SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type=”investigator” AND (wp_posts.post_status=”publish”) ORDER BY wp_posts.post_title ASC LIMIT 0, 6″ You can use name (or pagename) instead, but you cannot push raw SQL through like that. It … Read more

How can I implement jQuery plugin correctly with my CPT?

It looks like you’re looping 4 <ul class=”flex-unslider-ul”> items, do you not need to simply put the loop around the <li class=”flex-unslider-slide”> <?php $args = array( ‘post_type’ => ‘referanse’ ); $referanser = new WP_Query( $args ); if( $referanser->have_posts() ): ?> <ul class=”flex-unslider-ul”> <?php while( $referanser->have_posts() ): $referanser->the_post(); ?> <li class=”flex-unslider-slide”> <div class=”content”> <?php the_content(); ?> … Read more

Custom Post Type and Breadcrumbs Conflict

Your custom post type matches the conditional is_single(), so this part is trying to output the category the post is assigned to, which I’m assuming doesn’t exist: if (is_category() || is_single()) { $category = get_the_category(); $crumbs .= ‘<span typeof=”v:Breadcrumb”><a rel=”v:url” property=”v:title” href=”‘.get_category_link($category[0]->cat_ID).'”>’.$category[0]->cat_name.'</a></span>’; } either check if $category contains a category, or change is_single to just … Read more