Archived topic
Display content in single CPT
45 replies · Started by Eva on September 16, 2018
Hi Tom,
Excuse me please, for not getting back to you earlier... I have been working on another web site. Now I finally got back working on this one :-)
Actually I am still working on the tags, sorry for that.
I think most important is showing previous and next post. Do you have any suggestions for css styling?
By the way, I only use WP Show PostsPRO now to show the portfolio... much better! I have and will post some more questions on the WPSP forum.
Thank you again!
Eva
What are you wanting the links to look like? :)
Well, some space between <<project and project>> for a start :-)
Can you share what your function looks like now? We'll need to add some HTML markup to it so we can add CSS :)
I have send a message via the contact form at WPSP. Hope that's ok :-)
Hi Eva,
I have the link to your site here in the topic, but I wouldn't mind seeing the functions you're using to add those elements. That way I can tweak them to include the necessary HTML we need in order to style them.
As for the other things in your email - any chance you can send an email through our contact form here? Be sure to link to the topics you're providing information for.
Thanks!
Hi Tom,
Thanks. I am not sure I understand the questions about the functions, can you be more specific, please? And for the message I send via the other contact form I didn't keep a copy (stupid)... I will try to remember :-)
Thanks,
Eva
For example, this function I gave you: https://generatepress.com/forums/topic/display-content-in-single-cpt/page/2/#post-687043
I assume you had to make small changes before it worked for you? If not, I can make the changes to the above function and give it to you :)
Hey,
Although it was a lot a work for you to find out how to show, I decided to only use previous and next post for now, and maybe add categories/tags later (sorry!), or add related posts in a different way. So, for now I just used this function:
add_action( 'generate_after_content', function() {
if ( is_singular( 'project' ) ) {
previous_post_link();
next_post_link();
}
} );
Is this sufficient info?
Thanks again for the great support!
Sure, although I'm happy to help style the tags as well :)
So you'd use this function:
add_action( 'generate_after_content', function() {
if ( is_singular( 'project' ) ) : ?>
<div class="project-pagination">
<span class="previous-project">
<?php previous_post_link( '%link' ); ?>
</span>
<span class="next-project">
<?php next_post_link( '%link' ); ?>
</span>
</div>
<?php endif;
} );
Then you can use some CSS like this:
.project-pagination span {
display: inline-block;
margin-right: 10px;
}
Yessss! This works just fine. I made it 15px. By the way, could it be buttons too?
For the time being I stick to just previous and next. If my client wants to show categories and tags, I get back to you.
Thanks for all the help and support. I don't know where I would be without you guys :-)
You would need to remove the arrows, which the updated code above would do: https://generatepress.com/forums/topic/display-content-in-single-cpt/page/3/#post-698350
Then you could do this:
.inside-article .project-pagination a {
display: inline-block;
padding: 5px 10px;
background: #222;
color: #fff;
}
That works just fine!! I changed the CSS a bit for a different background and font-size, more distance between the buttons, and extra margin for the buttons on mobile:
.inside-article .project-pagination a {
display: inline-block;
padding: 5px 5px;
margin-right: 15px;
margin-bottom: 15px;
font-size: 14px;
background: #999;
color: #fff;
}
To me it looks alright. What do you think?
Thanks!!!
Looks good! :)
Thanks Tom, wouldn't have been possible if you hadn't been so patient :-) Thank you for the great support!