Jump to content

Devon808

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Devon808

  1. Bumping this to see how that parameter would look? Apologies as I am not at in a position to interpret this yet.
  2. @requinix can I get a lil assistance on what that might look like?
  3. @requinixThanks for replying. I still need the post title to render when viewing a post. Doesn't seem necessary, but that is what I am tasked with. The goal is to make this code work for other page/post types but omitting the post title for archive and search pages.
  4. I have someone else's code to update. My understanding of this logic is in progress, I'm more frontend - could use some help. I would like to programmatically remove the Post Title item from the Breadcrumb trail for archive and search pages. Otherwise, the last item in the trail. No CSS or JS, please. Current Results: Home > Blog > Category > Post Title The post title comes from the first item in the list of posts for the active category. Desired Results: Home > Blog > Category The code looks to be using Tightenco Collect package v8.0, but quite old as the github blame shows the last update was in 2019. <?php namespace Base; /** * Renders the breadcrumb trail */ class BreadcrumbTrail { public static function render($post) { $categories = collect(wp_get_post_terms($post->ID, ['category']))->sortBy('parent'); $breadcrumbs = $categories ->map(function ($term) { return self::render_item(get_category_link($term->term_id), $term->name); }) ->prepend(self::render_item(get_bloginfo('url'), get_bloginfo('name'))) ->push(self::render_item(get_permalink($post->ID), $post->post_title, 'active')); return self::wrap($breadcrumbs->implode('')); } public static function render_item($url, $title, $active = '') { $item = "<li class='breadcrumb-item %s'><a href='%s'>%s</a></li>"; return sprintf($item, $active, $url, $title); } public static function wrap($items) { ob_start(); ?> <div class="breadcrumb-container"> <ol class="breadcrumb-list"> <li class='breadcrumb-item'><a href='https://mydomain.com'>Home</a></li> <?php echo $items; ?> </ol> </div> </div> <?php return ob_get_clean(); } } A single header.php file is used for all pages with conditions set for specified page types. The class is echoed in the header.php file <?php echo \Base\BreadcrumbTrail::render(get_post()): ?> Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.