1

Okay - This may be a little elementary for some but I'm a bit confused here, and would love some insight. I have two sections of my website - my "Lessons" section, which is my main posts page, and an "Arrangements" section, which is a custom post type that I'm trying to get to act like my "Lessons" page, the Arrangements section doesn't show an Author, or Breadcrumbs.

For an example, see the following site: Personal Site

Problem:

On my Lessons section, I can see breadcrumbs:

Correct Breadcrumbs

And my author section comes up on single posts: Author

On the Arrangements section, the breadcrumbs do not work if you click through to a post, and neither does the Author Section.

Breadcrumbs should be "Home | Arrangements | Summertime", instead they look like:

Breadcrumbs

And author section is missing.

Author Section

Any ideas? Here's what I have so far:


My Lessons section is controlled by my index.php.

My Arrangements section is controlled by a custom Template file called arrangements.php.

In the arrangements.php file, I have the following loop:

$args = array(
    'post_type'   => 'arrangements',
    'post_status' => 'publish',
);

$new_post_loop = new WP_Query($args);
?>
<main id="primary" class="site-main">

    <?php
    if ($new_post_loop->have_posts()) :

        while ($new_post_loop->have_posts()) :

            $new_post_loop->the_post();

            get_template_part('template-parts/content', 'blog');

        endwhile;

        the_posts_navigation();

    else :

        get_template_part('template-parts/content', 'none');

    endif;

    wp_reset_postdata();

    ?>
5
  • 2
    WordPress does not have breadcrumbs, this will be provided either by a plugin or a theme, but even if it did, your arrangements post archive is not actually a arrangements archive, it's a page that has the same name that then pretends to be a arrangements archive by ignoring the main query. If you want your arrangements post archive to appear at a particular URL, there are solutions for that. Use archive-arrangements.php and adjust register_post_type so it uses that permalink – Tom J Nowell Jan 20 at 16:01
  • Hey Tom, I'm using them through Yoast. Okay, I'll give that a try! – Sackadelic Jan 20 at 18:00
  • You'll need to speak with Yoast dev support for the breadcrumbs part – Tom J Nowell Jan 20 at 19:54
  • Well, I copied my template file arrangements.php over to archive-arrangements.php, but I think I've found my problem. As I set a page with a template of arrangements.php, it's still drawing from page.php, not archive-arrangements.php. I'm unable to select an archive from a menu...I think? – Sackadelic Jan 20 at 20:21
  • 1
    You can set a URL. The name of the template file is coincidental though. The template does not determine the query, it's the other way around. E.g. if you intercepted the query and set s and unset some other flags, WordPress would instead think it's a search index and load search.php. In fact, when WordPress queries the database, it hasn't even attempted to pick a template file yet – Tom J Nowell Jan 20 at 21:34
1

When you declare your "Arrangements" custom post type, be sure to add 'author' and 'breadcrumbs' as parameters to the "supports" array. For example, it might look something like:

        $supports = array(
            'title',
            'author',
            'breadcrumbs',
            'editor',
            'excerpt',
            'thumbnail',
            'comments',
            'custom-fields',
            'revisions',
        );


        $labels = array(
            'name'                  => 'Arrangements',
            'singular_name'         => 'Arrangement',
            'menu_name'             => 'Arrangements admin menu'),
            'name_admin_bar'        => 'Arrangements add new on admin bar',
            'add_new'               => 'Add New Arrangement',
            'add_new_item'          => 'Add New Arrangement',
            'new_item'              => 'Add New Arrangement',
            'edit_item'             => 'Edit Arrangement',
            'view_item'             => 'View Arrangement',
            'all_items'             => 'All Arrangements',
            'search_items'          => 'Search Arrangements',
            'parent_item_colon'     => 'Parent Arrangement:',
            'not_found'             => 'No Arrangement Found',
            'not_found_in_trash'    => 'No Arrangements found in trash',
            'filter_items_list'     => 'Filter Arrangements',
            'items_list_navigation' => 'Arrangements list navigation',
            'items_list'            => 'Arrangements list',
        );      

        $args = array(
            'labels'          => $labels,
            'supports'        => $supports,
            'public'          => true,
            'capability_type' => 'post',
            'rewrite'         => array( 'slug' => 'arrangements', 'with_front' => false ),
            'menu_position'   => 2,// or whatever
            'menu_icon'       => ( version_compare( $GLOBALS['wp_version'], '3.8', '>=' ) ) ? 'dashicons-admin-generic' : false ,// or whatever
            'has_archive'     => true,
        );

        register_post_type( 'arrangement', $args );

That should sort out the author section display issue. Hopefully it will address the breadcrumbs as well. If not, then as another user suggested, the Yoast breadcrumbs may involve additional complexity.

Reference: https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/

1
  • I got it now - thanks so much! I appreciate the help here. – Sackadelic Jan 21 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.