Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected

The issue was, in fact, the new taxonomy using “year” clashes with the query. WordPress was accepting year=about-us in the query chain for instance, as year was a taxonomy, before the expected page=about-us – preventing it from appearing as a page and using the index.php template as there is no “year” template. I changed year … Read more

How to change custom post type slug without damage seo? [closed]

You can do this without losing SEO. Change the taxonomy slug from “watches-product” to “watches/product” register_taxonomy(‘wpsc_watch_product_category’, ‘wpsc_watch_product’, array( ‘hierarchical’ => true, ‘query_var’ => ‘watch_product_category’, ‘rewrite’ => array( ‘slug’ => ‘watches/product’ ), ‘labels’ => $labels, )); Install a 302 Redirect Plugin. This plugin will redirect all the traffic to new url.

Trying to list custom categories in custom post type [closed]

Try this, you can’t just throw a conditional block inside an echo statement. If you really need to it has to be a shorthand if-else, but for visual purposes I have put the statement outside the loop: $taxonomy = ‘product-categories’; $tax_terms = get_terms( $taxonomy ); foreach($tax_terms as $tax_term) { $terms = apply_filters( ‘product-categories-images-get-terms’, ” ); … Read more

Custom Field Search

Use pre_get_posts to filter search results: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, ‘custom_post_type_name’); $query->set(‘cat’, intval($_POST[‘cat’]); // assuming you have a select with categories with name “cat” } } } add_action(‘pre_get_posts’,’search_filter’);

custom texonomy category child category list with parent head

well i just got a solution like this >> <?php $taxonomyName = “com_category”; $parent_terms = get_terms($taxonomyName, array(‘parent’ => 0, ‘orderby’ => ‘slug’, ‘hide_empty’ => false)); foreach ($parent_terms as $pterm) { $terms = get_terms($taxonomyName, array(‘parent’ => $pterm->term_id, ‘orderby’ => ‘slug’, ‘hide_empty’ => false)); foreach ($terms as $term) { echo ‘<div class=”single_cat col-md-3″>’; echo ‘<h3>’.$pterm->name.'</h3>’; echo “<ul>”; … Read more

Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT

OK, so finally after searching for days i was able to solve my problem!! Just had to remove these two lines of code: $terms = wp_get_post_terms( $post->ID, ‘service_cat’ ); foreach($terms as $term) { With this line instead: $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); And that solved my issue!! Thanks also … Read more

Get all active posts that are tied to a custom taxonomy for a custom post type

Here’s how I fixed it.. <!–faq page –> <div class=”faq”> <?php get_template_part(‘./template/global/breadcrumbs’); ?> <h3><span><?php the_title(); ?></span></h3> <?php $categories = get_categories(‘taxonomy=faqcat&order=DESC’); foreach ($categories as $cat) { $i = 0; ?> <div class=”faq-title”> <h2><?php echo $cat->name; ?></h2> </div> <?php $answers = new WP_Query(array(‘post_type’ => ‘faq’, ‘tax_query’ => array(array(‘taxonomy’ => ‘faqcat’, ‘field’ => ‘id’, ‘terms’ => $cat->term_id,),),)); if … Read more