Site logo

Archived topic

Display content in single CPT

45 replies · Started by Eva on September 16, 2018

Viewing posts 1–15 of 46

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

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 :)

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

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.

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!

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();
    }
} );

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!

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

Hi David,
Thank you for your reply, but unfortunately this doesn't work either...

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?

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!

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?

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.

This archived topic is closed to new replies.