-
hollytga
Hi,
I cannot get the post navigation block to work on either a regular blog post or a custom post type.I have the php from your docs entered to enable a CPT to work with navigation. I am using an element (Block-Loop template) for the regular posts as well as the CPT posts (projects). And I am using the element Block-post navigation for the navigation on both post types.
Any ideas? Here is the site: https://proficient.fresheggs.biz/
Thank you.
-
Alvind
Hi there,
Could you link us to the page URL that contains this navigation? I don’t seem to find it on the site you provided.
Also, what PHP snippet are you using? If you’re using the Block Element for the Post Pagination, I don’t think you require any snippet to make it work.
Let us know!
-
hollytga
It’s on this page https://proficient.fresheggs.biz/portfolio/
I can see it in the editor but not on the front end.This is the snippet:
add_action( ‘generate_after_entry_content’, ‘tu_cpt_footer_meta’ );
function tu_cpt_footer_meta() {
if ( is_singular( ‘project’ ) ) : ?>
<footer class=”entry-meta”>
<?php generate_entry_meta(); ?>
<?php generate_content_nav( ‘nav-below’ ); ?>
</footer><!– .entry-meta –>
<?php endif;
} -
hollytga
I turned off the snippet and now it’s working. not sure what I thought I needed it now as it’s been a few days.’
I may be back later when I get to that point again. Thanks! -
Alvind
No problem! Just let us know anytime if you encounter the same issue again 🙂
-
hollytga
Ok. Back to it. The navigation works on a page. But doesn’t work when in an element. I have an element with that is a block>element type:post navigation and want it to display on all single blog posts and archive pages. Here is a sample blog post that it should be diplaying on.
https://goldberg.fresheggs.biz/welcome-to-your-new-website-copy/
Thanks! -
Are the posts using a block element – loop template?
If so, the default content area has been replaced by the loop template, so there’s no more
generate_after_entry_content
hook and any content inserted via that hook will no longer work.And in your code, you have this condition
is_singular( 'project' )
, which means the code will only execute if it’s a single project page.So try to change your PHP code to this to convert it to a shortcode:
function tu_cpt_footer_meta_shortcode() { if (is_singular()) { ob_start(); ?> <footer class="entry-meta"> <?php generate_entry_meta(); ?> <?php generate_content_nav('nav-below'); ?> </footer><!-- .entry-meta --> <?php return ob_get_clean(); } return ''; // Return empty string if condition is not met } add_shortcode('custom_footer_meta', 'tu_cpt_footer_meta_shortcode');
Then add this shortcode
[custom_footer_meta]
to your loop template. -
hollytga
Thanks Ying. Yes the posts and projects are using a block element – loop template.
It works now but there is a duplicate navigating on the page. And the style is not the same as what I have in the navigation element. https://proficient.fresheggs.biz/welcome-to-your-new-website-2/
-
Try removing this line:
<?php generate_content_nav('nav-below'); ?>
-
hollytga
Great. That got rid of the duplicate. But why is the style not the same as I have in the element? It is showing stacked titles of the previous and next instead of a row with “previous” and “next”.
Thanks!
-
But why is the style not the same as I have in the element?
Can I see the element with the proper style?
-
hollytga
Here is the element. https://drive.google.com/file/d/1N9J5Ssn-eh6_OdAH83I56z2WZ4QgiHHY/view?usp=sharing
I just realized it was turned off. When the element is turned off there is navigation as you can see in the page I sent. When it’s turned off there is no navigation other than the category. I want to be able to use nagivation across posts and projects (a CPT) and be able to style it – which is why I was using an element.
Thanks.
-
The PHP code would only output the default GP theme post meta, so it’s the correct style as how GP style them.
But your post navigation element is NOT valid, it’s pagination, not post navigation, it’s supposed to be shown on archives, not single posts.
If you want to create post navigation on single posts/cpts via GP element, then you do not need that PHP code or the shortcode, you can use the element alone.
And the post navigation element has built-in templates, you can simply import one and modify its style to your liking:https://app.screencast.com/Um4rTyNQcVgV7
-
hollytga
Now I am really confused.
I’d like pagination to look the same on all single posts, CPTs and archives. So what is the most efficient set-up?I appreciate the help.
-
Single posts usually do not have paginations, to better assist you, may I see a post that requires pagination?
-
hollytga
You are right. As I said I am getting confused. I meant navigation between posts and pagination on archive pages.
Let’s just figure out the navigation. When I turn off the snippet, take out the short code and use an element. It does not show on the posts. I am using a block loop template for the posts.
Thank you for your patience.
- You must be logged in to reply to this topic.