[Resolved] Entry meta not displaying for a CPT

Home Forums Support Entry meta not displaying for a CPT

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1269897
    Matthew

    The entry meta appears as below for a regular post, after the content:

    https://drive.google.com/open?id=1dM0VASR9gAXDYD67qyekMqyShSXEqqYu

    No such luck with a custom post type however.

    I have also tried so with and without the below function previously suggested:

    add_filter( 'generate_footer_meta_posts_types', function( $types ) {
        $types[] = 'pictures';
    
        return $types;
    } );

    Any advise appreciated.

    thanks,

    #1270803
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can edit the original topic and use the private URL field.

    Let me know 🙂

    #1271417
    Matthew

    Hi Leo,

    I just sent you some site links and my admin login URL with user name and password using your account issue form (as requested by David for previous topics) because you may have trouble reading the U/P in the URL field due to the formatting there.

    Code snippets are in my site-specific plugin ‘imjexa-plugin’.

    thanks,

    #1272305
    Leo
    Staff
    Customer Support

    Any chance you can try the snippets using one of these methods first?
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1274954
    Matthew

    Still no sausage.

    I installed the Code Snippets plug-in and added that function. The site-specific plug-in I use is rarely the source of problems. But Code Snippets looks handy and I will probably use that from now on.

    Are the settings on the Customizer meant to also work for custom post types? Currently it’s not, and the template files I copied and used for the CPT are unchanged from the original ones i.e. single.php and content-single.php

    #1275655
    Tom
    Lead Developer
    Lead Developer

    Hi Matthew,

    The “Pictures” section on your site doesn’t seem to be using a custom post type. It looks like a static page which links to the attachment page for an image.

    Are you wanting to add entry meta to all of your attachment pages?

    Let me know 🙂

    #1278405
    Matthew

    That’s a static page I created to act as a gallery page or point users can access my work. It links to the attachment page for media where I have image galleries set up to show additional images. It’s a related but separate aspect.

    So what I’m talking about my custom post type ‘Pictures’. It’s there

    https://drive.google.com/open?id=1N9LmZzAAmmZutRvdO3YdkBLyiZMgjZn-

    Just getting that post to function like a normal post, and show the entry meta.

    A test post (of a regular post):

    https://drive.google.com/open?id=1dM0VASR9gAXDYD67qyekMqyShSXEqqYu

    That meta at the bottom I cannot get to appear on any post of my CPT.

    #1279407
    Tom
    Lead Developer
    Lead Developer

    Has the username/password changed for your site? I can’t get in.

    Let me know 🙂

    #1280028
    Matthew

    Changed from where sorry? I hadn’t put it into this topic.

    Could you pls check my last submission from the account issue form which was was only recently, as I send it that way from now on (at David’s recommendation) because it formats unreadable in the URL field of my original topic.

    Looking forward to it.

    #1280031
    Matthew

    It’d be awesome if we could keep the login in our profile or if there was a separate user name and password field instead of just the URL field on that original topic so formatting is not jumbled, as it’s regularly the cause for delay.

    #1281208
    Tom
    Lead Developer
    Lead Developer

    That would be awesome – I’ll look into that.

    I see the issue, your filter is spelled incorrectly.

    Try this:

    add_filter( 'generate_footer_meta_post_types', function( $types ) {
        $types[] = 'pictures';
    
        return $types;
    } );
    #1281865
    Matthew

    That’s now showing the next/previous post navigation but I’m still not getting the categories and tags. See screenshot they should be above the navigation:

    https://drive.google.com/open?id=1iMPP_Bxj2wtXZE_KgxbZFGBRipzcyPyR

    (Above that is the last of the post content, and below is my template content).

    What do you think it is.

    The CPT code is in my site-specific plug-in. I have the CPT-UI plug-in installed and I could try setting up the CPT using that instead. But only if you think this is worth it to check. And if I delete my CPT code from my plug-in then re-create it with the same CPT names and taxonomies will all my existing posts be preserved would you know?

    thanks,

    #1282756
    Tom
    Lead Developer
    Lead Developer

    Does your CPT support the standard category/post tag taxonomies, or does it have custom taxonomies?

    The standard GP code will only work with the standard taxonomies, so if you’re using custom ones we’ll need to add functions to output those links.

    #1283429
    Matthew

    When i set up the CPT ‘Pictures’ yes I thought there should be taxonomies for it as well, so created,

    One for categories

    function custom_taxonomy_genres()

    and one for tags

    function custom_taxonomy_words

    #1284466
    Tom
    Lead Developer
    Lead Developer

    In that case, you need to do something like this:

    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'genres' === $item ) {
            $genres_list = get_the_term_list( get_the_ID(), 'genres', '', ', ' );
    
            if ( $genres_list ) {
                printf(
                    '<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
                    esc_html_x( 'Genres', 'Used before tag names.', 'generatepress' ),
                    $genres_list,
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'genres' )
                );
            }
        }
    
        if ( 'words' === $item ) {
            $words_list = get_the_term_list( get_the_ID(), 'words', '', ', ' );
    
            if ( $words_list ) {
                printf(
                    '<span class="tags-links">%3$s<span class="screen-reader-text">%1$s </span>%2$s</span> ',
                    esc_html_x( 'Words', 'Used before tag names.', 'generatepress' ),
                    $words_list,
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'words' )
                );
            }
        }
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        if ( 'pictures' === get_post_type() ) {
            return array(
                'genres',
                'words',
                'comments-link',
            );
        }
    
        return $items;
    } );
    
    add_filter( 'generate_footer_meta_post_types', function( $types ) {
        $types[] = 'pictures';
    
        return $types;
    } );
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.