Multiple categories assigned to a single product breaking the breadcrumb
Multiple categories assigned to a single product breaking the breadcrumb
Multiple categories assigned to a single product breaking the breadcrumb
Try to change this part: echo $before . ‘Search results for “‘ . get_search_query() . ‘”‘ . $after; To this: $searchTerm = get_search_query() echo $before . ‘Search results for “‘ . $searchTerm . ‘”‘ . $after;
For question 1, use a custom field when you create the page and use the same template each time. Here is an example using a custom field named house_type. <?php // Template Name: House Type [ … ] $house_type = get_post_meta( get_queried_object_id(), ‘house_type’, true ); $args = array ( ‘post_type’ => ‘house’, ‘orderby’ => ‘meta_value’, … Read more
That plugin represents a fair bit of code to read through but I did not see any obvious way to prioritize/eliminate/ignore categories in the way you want. I would suggest that you stop abusing categories and convert your code to use post meta (probably) instead of categories to ” to assign specific properties to given … Read more
I’m not sure if you want it like this, however, this can be achieved by CSS. .crumbs > span > span + span { margin-left: 1em; } .crumbs > span > span + span:before { content: ‘|’; /* or something else */ *display: inline; display: inline-block; margin-left: -1em; width: 1em; text-align: center; } // EDIT … Read more
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
Doing same thing in more concise way: function breadcrump_page( $post ) { $format=”<a href=”https://wordpress.stackexchange.com/questions/140362/%s” title=”https://wordpress.stackexchange.com/questions/140362/%s”>%s</a> >”; $anc = array_map( ‘get_post’, array_reverse( (array) get_post_ancestors( $post ) ) ); $links = array_map( ‘get_permalink’, $anc ); foreach ( $anc as $i => $apost ) { $title = apply_filters( ‘the_title’, $apost->post_title ); printf( $format, $links[$i], esc_attr($title), esc_html($title) ); } … Read more
I’m still not one hundred percent sure where and what needs to be displayed. If you need to show the current single post’s category, you’ll need to use get_the_category in stead of the_category as the_category needs to be called inside the loop. You can use get_the_category as follow (Remember to use the global $post to … Read more
Suppose you have set up an array of page IDs where you don’t want the breadcrumbs to be displayed. $ids = array( 4, 8, 15, 16, 23, 42 ); Now you just have to check if the currently displayed page (or post) has one of these IDs, and if not, display the breadcrumbs. if ( … Read more
Ok, so I didn’t get a reply, but I worked this out as as solution and I hope it will be useful to others. I am using the evolve template, so when you see evolve it is referring to something in the evolve template; e.g. evolve_breadcrumb() is a function used by the evolve template. This … Read more