• I’m new to using custom post types so forgive my ignorance…

    Ever since I set up a custom post type (which is displayed on every page of the site), the breadcrumbs now read: ‘Home > Custom post type title’ for each page. Obviously I’d like them to show the title of the actual page rather than the title of the custom post type.

    Appreciate any help, thanks.

    PS. The breadcrumb titles work just fine for posts (the post title is displayed), but not for pages.

    https://ww.wp.xz.cn/plugins/breadcrumb-navxt/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Havlik

    (@mtekk)

    You are likely running a second loop that is redefining the $post variable, please do not do that. At a minimum, backup the $post variable before your secondary loop and then restore it after the secondary loop has run. But, in general, modifying/using $post in secondary loops is not recommended.

    Thread Starter andyweb

    (@andyweb)

    Hi John, thanks …I’m not sure if I am, what I have is this code in header.php straight after the </head> tag to call my custom post type, before any other php is included.

    <?php
       $args = array( 'post_type' => 'hero_slider', 'posts_per_page' => -1 );
        $daloop = new WP_Query( $args );
        while ( $daloop->have_posts() ) : $daloop->the_post();
        ?>
        <li>
            <img src="<?php the_field('slider_image'); ?>" alt="" class="sliderimg" />
            <div class="overlay">
                    <div class="container cf">
                        <div class="contents">
                            <p class="title"><?php the_title(); ?></p>
                            <p><?php the_content(); ?></p>
                            <p class="link"><a href="<?php the_field('link_url'); ?>"><?php the_field('link_text'); ?></a> </p>
                        </div>
                    </div>
             </div>
         </li>
      <?php
        endwhile;
      ?>

    I’m using a different breadcrumb plugin (instant breadcrumbs) for now which gets it right, so it’s no biggie. Still would be good to understand the issue.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Don't show custom post type title’ is closed to new replies.