- This topic has 20 replies, 3 voices, and was last updated 4 years ago by
David.
-
AuthorPosts
-
February 27, 2019 at 8:32 am #823539
Michele
Hi guys! I’m working on a new project and I’d love to use the custom post navigation from Volume (site library).
The GP element is doing its job on the single post template, but how can make It work on May custom post type as well?
PS: already tried the display rules with no effects
Thanks in Advance!
GeneratePress 2.2.2GP Premium 1.7.8February 27, 2019 at 8:39 am #823548David
StaffCustomer SupportHi there,
if you go to Appearance > Elements –> Edit the Custom Post navigation
Does your post type show up in the Display rules? Currently it is set to display on the single Post.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 27, 2019 at 8:46 am #823556Michele
Ehi David,
Yep, it shows up, but if I set in addiction my cpt that element is applied anyway only to normal posts.February 27, 2019 at 9:04 am #823578Tom
Lead DeveloperLead DeveloperAny chance you can show us a screenshot of your Display Rules, and link us to one of your custom post types posts?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 27, 2019 at 9:10 am #823590Michele
Ehi Tom!
Here you have the screenshot of my element’s settings:And this is a link to one of my custom post type > https://www.graffette.net/case-history/la-bionda/
Thanks in advance!
February 27, 2019 at 4:54 pm #823903Tom
Lead DeveloperLead DeveloperThat post seems to be a post inside the
case-history
post type. What if you add that Case History cpt to your Display Rules?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 28, 2019 at 12:32 am #824104Michele
Nope Tom, I have just one custom post type on this website. It’s just a matter of labelling, as you can see:
function cptui_register_my_cpts_case_history() { /** * Post Type: Progetti. */ $labels = array( "name" => __( "Progetti", "custom-post-type-ui" ), "singular_name" => __( "Progetto", "custom-post-type-ui" ),...
February 28, 2019 at 9:15 am #824736Tom
Lead DeveloperLead DeveloperDo you have anything registered as
case-history
?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentFebruary 28, 2019 at 9:28 am #824746Michele
Nope Tom, just the cpt I mentioned above and a custom taxonomy named
categoria_progetti
.Why you ask me this?
February 28, 2019 at 5:14 pm #825088Tom
Lead DeveloperLead DeveloperThe post you linked me to has this class added to the body element: https://www.screencast.com/t/wTSA9s9lV46
WordPress only adds the
single-xx
class with the name of the custom post type. So as far as the code is showing, that post is a part of a custom post type named “Case History”.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 1, 2019 at 12:57 am #825293Michele
mmm… Yes, the cpt is named “case_history” but simply I changed the labels for being more italian friendly.
Indeed, as you can see, I used another element to show something only on that specific cpt archive. This is the secundary navigation (in the element UI you can read ‘Progetti’:
In this page you can see it in action.
So I think the problem is not the cpt name, but something maybe in the element code not compatible?
<div id="post-nav"> <?php global $post; $prevPost = get_previous_post(false); if($prevPost) { $args = array( 'posts_per_page' => 1, 'include' => $prevPost->ID ); $prevPost = get_posts($args); foreach ($prevPost as $post) { setup_postdata($post); ?> <a class="post-previous" href="<?php the_permalink(); ?>"> <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.1),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url("large"); ?>');"> <div class="post-nav">Precedente</div> <h3 class="post-nav-title"><?php the_title(); ?></h3> </div></a> <?php wp_reset_postdata(); } //end foreach } // end if $nextPost = get_next_post(false); if($nextPost) { $args = array( 'posts_per_page' => 1, 'include' => $nextPost->ID ); $nextPost = get_posts($args); foreach ($nextPost as $post) { setup_postdata($post); ?> <a class="post-next" href="<?php the_permalink(); ?>"> <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.6),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url(); ?>');"> <h3 class="post-nav-title"><?php the_title(); ?></h3> <div class="post-nav">Successivo</div> </div></a> <?php wp_reset_postdata(); } //end foreach } // end if ?> </div>
March 1, 2019 at 9:03 am #825778Tom
Lead DeveloperLead DeveloperHmm, which hook are you adding it to?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 1, 2019 at 9:50 am #825824Michele
The secundary navigation is shown in the
after_archive_title
hook, while the custom post navigation is inbefore_footer
.Then I’ve added some php to show the post meta, comments etc.. But I prefer to give you the code maybe in a private session, if it’s possible. Is it?
March 1, 2019 at 4:45 pm #826084Tom
Lead DeveloperLead DeveloperI think I see the issue.
get_previous_post()
andget_next_post()
don’t seem to work with custom post types by default.Did some searching and didn’t find anything concrete, unfortunately. One thing you could try is replacing:
get_previous_post(false);
With:
get_previous_post(true);
And
get_next_post(false);
With:
get_next_post(true);
Not sure if it will work, but it’s worth a shot.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 2, 2019 at 12:12 am #826241Michele
Ehi Tom, I tried to apply your tip but it didn’t work. 🙁
-
AuthorPosts
- You must be logged in to reply to this topic.