[Resolved] Display content in single CPT

Home Forums Support [Resolved] Display content in single CPT

Home Forums Support Display content in single CPT

Viewing 15 posts - 1 through 15 (of 46 total)
  • Author
    Posts
  • #678728
    Eva

    Hi,
    I am using GPP for a site with a filterable portfolio. I used the Meta Box plugin to make a CPT and Content Views Pro to show the filterable portfolio. It seems to work fine. But I would like to display tags and navigation on the single portfolio pages and I can’t get it done… I think I might need to make a template for the single portfolio items. Any suggestions?
    Thanks,
    Eva

    #678838
    Tom
    Lead Developer
    Lead Developer

    Hi Eva,

    So are the single portfolio pages a custom post type?

    If so, you could try something like this:

    add_action( 'generate_after_content', function() {
        if ( is_singular( 'your-post-type-name' ) ) {
            the_posts_pagination();
        }
    } );

    Let me know ๐Ÿ™‚

    #678987
    Eva

    Hi Tom,
    Thanks for your prompt reply. Unfortunately this didn’t work… I made a custom post type for the portfolio items because there will be news items too. So, the single portfolio pages are a custom post type. But I didn’t make a special template to show the portfolio items, if that is what you mean. I am sorry for the confusion. Hope I managed to make myself clear, and you can help me resolve the problem.
    I have another question about custom fields, but I will make a new topic.
    Thanks again. Great support, as always!
    Eva

    #679451
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Did you replace your-post-type-name with the name of your custom post type? Templates themselves shouldn’t matter as long as the ID of the post type matches.

    #679556
    Eva

    Hi Tom,
    Yes I did, and I tried everything I could think of…
    I used ‘project’ because: register_post_type( ‘project’, $args );
    I also tried ‘Project’ and ‘Projecten KPG’ because: ‘label’ => esc_html__( ‘Projecten KPG’, ‘text-domain’ ),

    The strange thing is that I can change the featured image (on/off, size), but I can’t change anything in the Single Content.

    Thanks!

    #679758
    Tom
    Lead Developer
    Lead Developer

    project should work.

    If you replace your function with the below, do you see the testing message?:

    add_action( 'generate_after_content', function() {
        if ( is_singular( 'your-post-type-name' ) ) {
            echo 'testing';
            the_posts_pagination();
        }
    } );
    #679846
    Eva

    Hi Tom,
    I have tried and yes, I do see ‘testing’ below the content of the post ๐Ÿ™‚
    Hope you can tell me what to do the next.

    Thanks!

    #680360
    Tom
    Lead Developer
    Lead Developer

    I just made a change to the code above, can you give it another shot?: https://generatepress.com/forums/topic/display-content-in-single-cpt/#post-678838

    #680532
    Eva

    Hi Tom,
    Uhm… don’t think this works…
    Fatal error: Call to undefined function the_post_pagination() in /…/…/….nl/wp-content/themes/generatepress_child/functions.php on line 86

    Sorry for all this…
    Thanks again,
    Eva

    #680635
    David
    Staff
    Customer Support

    Hi there,

    can you double check the code you have added, Tom made an amend to the above. Note the undefined function is the_post_pagination() in Tom’s code it is the_posts_pagination()

    I would recopy and paste the code here:

    https://generatepress.com/forums/topic/display-content-in-single-cpt/#post-679758

    #681101
    Eva

    Hi David,
    Thank you for your reply, but unfortunately this doesn’t work either…

    #681319
    Tom
    Lead Developer
    Lead Developer

    Ah, sorry about that – typed the function wrong.

    the_posts_pagination() should be working, but it’s not outputting anything. Can re-add the original code that calls to the_posts_pagination() so I can inspect the code?

    #681390
    Eva

    Yep, just did. It’s now back to:

    add_action( ‘generate_after_content’, function() {
    if ( is_singular( ‘project’ ) ) {
    the_posts_pagination();
    }
    } );
    Just to make sure, in the Child: functions.php.

    I can make you a login, if you like..

    Thanks!

    #681799
    Tom
    Lead Developer
    Lead Developer

    This is super strange – some markup should at least be printed.

    Do you have any other functions on the site?

    Is the post navigation disabled in “Customize > Layout > Blog”? If so, what happens if you enable that option?

    #681864
    Eva

    I have another function and took it out to see what happens… nothing. Then I (de)activated some plugins: nothing.
    I also enabled/disabled all options in the Blog layout… nothing.
    Just to make sure: I added the function to the functions.php in the child theme.

Viewing 15 posts - 1 through 15 (of 46 total)
  • You must be logged in to reply to this topic.