Viewing 7 replies - 1 through 7 (of 7 total)
  • Mark

    (@delayedinsanity)

    get_queried_object() might work for you?

    $obj = get_queried_object();
    $name = $obj->name;
    $slug = $obj->slug;

    As for the permalink structure, it’s definitely possible, but it would require a bit of custom programming which is wildly outside the scope of the project as it currently stands. Let me know if I can help with anything else!

    Thread Starter Russ Powers

    (@russwebguy)

    get_queried_object() worked great on the category pages, but not single listings for some reason. I’m thinking a new function may have to be created to properly display the category names and slugs on the single.php template file.

    I’ll do some experimenting to see if I can write a complete breadcrumbs function for parent categories, child categories, and single posts. If I come up with something concrete, I’ll definitely share it if you want to include it in a future update or something ?? Same with the permalink structures.

    The overall design and functionality of this plugin is amazing and exactly what I’m looking for so I’m definitely going to stick with it.

    Mark

    (@delayedinsanity)

    I haven’t tested it, but have you tried using the breadcrumbs in Yoast’s WordPress SEO plugin? Probably the best breadcrumb trail generator available, I’d be interested to know if I needed to update the plugin in any way to make it fully compatible.

    Thread Starter Russ Powers

    (@russwebguy)

    I’ve tried the breadcrumbs tool from Yoast’s WordPress SEO plugin, but it really didn’t work. What I would like to accomplish is having a breadcrumb like so..

    Directory Home Page >> Category Name >> Listing

    I have been able to get a primitive breadcrumb to work on the category pages, but I can’t figure out how to hook in the category name and url on the single listing template. Once I get that down, we should have fully functional breadcrumbs! If I figure it out, I’ll send you copies to possibly implement in a future update ??

    I’ve also ran into another minor thing with tag permalinks, I couldn’t find any resources for this. I’m using the tags to group listings by city, but I can’t figure out the alternative permalink the following..

    https://www.mysite.com/?listing_tag=los-angeles

    I’m pretty sure there’s a way but can’t seem to figure it out lol

    Thread Starter Russ Powers

    (@russwebguy)

    ^ oh related to my last post above ^

    Is there a way to query the parent category name and slug when viewing a sub category?

    Thread Starter Russ Powers

    (@russwebguy)

    I’ve figured out a way to include breadcrumbs!!! I’ve provided the scripts I wrote below along with instructions!!! Enjoy! ??

    I added the following code to the category.php tempate file

    <a href="../../directory">Directory</a> // Replace with the page slug and name you use for the directory home page.
    <?php
    $product_terms = wp_get_object_terms($post->ID, 'listing_category');
    $subs = ldl_get_categories(get_queried_object()->term_id );
    if(($subs) || is_tax( 'listing_tag' )) { // tags doesn't have sub categories so we exclude them
    	echo '&raquo; '.get_queried_object()->name;
    } else {
    	if(!empty($product_terms)){
    	  if(!is_wp_error( $product_terms )){
    		foreach($product_terms as $term){
    		  echo '&raquo; <a href="'.get_term_link($term->slug, 'listing_category').'">'.$term->name.'</a>';
    		}
    	  }
    	}
    }
    ?>

    I added the following code to the single.php template file

    <a href="../../directory">Directory</a> &raquo; // Replace with page slug and name you use for the directory home page.
    <?php
    $product_terms = wp_get_object_terms($post->ID, 'listing_category');
    if(!empty($product_terms)){
      if(!is_wp_error( $product_terms )){
        foreach($product_terms as $term){
          echo '<a href="'.get_term_link($term->slug, 'listing_category').'">'.$term->name.'</a> &raquo; ';
        }
      }
    }
    ?><?php the_title(); ?>

    SIDE NOTE::

    If you are using sub categories and the bread crumb comes back as “Directory >> Sub-Category >> Parent Category >> Listing Title” you can make the following modification to the foreach loops:

    foreach(array_reverse($product_terms) as $term){

    Hope this helps!!

    Thread Starter Russ Powers

    (@russwebguy)

    So I notice a bit of a glitch with my last post. It seems that the categories will display backwards randomly. So I’ve wrote a fresh script that will prevent the categories from being displayed backwards. I’m going to resolve this topic and start a new one for breadcrumbs

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Category name and slug on listing’ is closed to new replies.