- This topic has 30 replies, 4 voices, and was last updated 4 years, 9 months ago by Leo.
-
AuthorPosts
-
May 30, 2019 at 12:25 am #915026Elia
Hi Tom,
Thanks for the reply! I added all the information in the first post, please take a look.
Also please be careful because it’s a live website
May 30, 2019 at 8:29 am #915462TomLead DeveloperLead DeveloperAny chance you can share the functions you’re using in here? I wasn’t able to login with the password you provided.
Let me know 🙂
May 30, 2019 at 8:52 am #915494EliaI put all the information in the first page but your website changed it to something unreadable..
This time I only put a link to a code. Please have a look my first post here
I only changed 2 things:
1) Change “Category C” to the actual name of the category (not sure if this is correct because usually we used the ID).
2) Change the ID from 10 to 40Thanks a lot
May 30, 2019 at 8:56 am #915495TomLead DeveloperLead DeveloperMaybe try the ID in
has_category()
instead of the name.May 30, 2019 at 9:03 am #915503EliaThis doesn’t work sorry
May 30, 2019 at 4:16 pm #915821TomLead DeveloperLead DeveloperWhat if the ID doesn’t have quotations around them?
Technically it should work, so there must be something conflicting somewhere. Can you link me to a post where the code should be working?
May 31, 2019 at 12:17 am #915990EliaI tried the ID without quations – still no result.
Also I tried to apply the same code on the dev website and see this issue:
https://gyazo.com/07fde5aaf4682649c2de2561d5ed9143Do you have a chance to apply and test the code on your side?
May 31, 2019 at 2:46 pm #916648TomLead DeveloperLead DeveloperI’ve been playing with this and unfortunately it’s incredibly complex. I played with the code David provided in the other topic, but I’m still not sure it’s working:
<div id="custom-post-nav" class="post-nav-grid"> <?php global $post; $post = get_queried_object(); $post_type = get_post_type(); if ( has_category( 4 ) ) { $prevPost = get_previous_post( true, array( 4 ) ); } else { $prevPost = get_previous_post(); } if($prevPost) { $args = array( 'posts_per_page' => 1, 'include' => $prevPost->ID, 'post_type' => $post_type ); $prevPost = get_posts($args); foreach ($prevPost as $post) { setup_postdata($post); ?> <a class="post-previous" href="<?php the_permalink(); ?>"> <span class="nav-icon">❮</span><span class="post-nav-label">Previous Article</span> <h5 class="post-nav-title"><?php the_title(); ?></h5> </a> <?php wp_reset_postdata(); } //end foreach } // end if if ( has_category( 4 ) ) { $nextPost = get_next_post( true, array( 4 ) ); } else { $nextPost = get_next_post(false); } if($nextPost) { $args = array( 'posts_per_page' => 1, 'include' => $nextPost->ID, 'post_type' => $post_type ); $nextPost = get_posts($args); foreach ($nextPost as $post) { setup_postdata($post); ?> <a class="post-next" href="<?php the_permalink(); ?>"> <span class="post-nav-label">Next Article</span><span class="nav-icon">❯</span> <h5 class="post-nav-title"><?php the_title(); ?></h5> </a> <?php wp_reset_postdata(false); } //end foreach } // end if ?> </div>
It’s worth trying. Just make sure to remove the other filters we’ve added in this topic.
May 31, 2019 at 11:18 pm #916812EliaHi Tom!
Thanks a lot!
I’ve applied the code from this topic https://generatepress.com/forums/topic/change-the-style-for-the-previous-next-section/page/2/#post-916642
The Previous/Next section is looking nice and working!
The only task that is not working yet is to exclude the category from the Previous/Next section.
If my category ID is 40 do I have to change 4 to 40 in the code above? I tried both and they don’t work
June 1, 2019 at 4:13 pm #917339TomLead DeveloperLead DeveloperAh yes sorry – you’ll need to update it to
40
. I was afraid that would be the case, it’s pretty complex unfortunately.I’m only on emails for the weekend, but I can play with it a little more on Monday when I’m back at the coding computer.
June 2, 2019 at 5:45 am #917601EliaHi Tom, thanks a lot!
Sad to hear that it’s a difficult task. Could we perhaps tackle it differently?
We now have 2 main things on the website:
1) A blog about variety topics
2) RecipesThe idea is to somehow isolate second Recipes from the blog
June 2, 2019 at 7:31 am #917803TomLead DeveloperLead DeveloperHave you explored using a custom post type for the recipes? That way you would have “Posts” for your variety of topics, and “Recipes” for your recipes.
Let me know 🙂
June 3, 2019 at 2:24 am #918261EliaThanks Tom!
No I didn’t try the custom post type.
Where can I try this? Would this resolve our issue with the navigation?
Can I use it without installing any plugins? Because we already have a lot of plugins which affects the speed of our website
June 3, 2019 at 7:48 am #918618LeoStaffCustomer SupportThe easiest way to use a plugin (this is what I used) – should have minimal impact on your site:
https://en-ca.wordpress.org/plugins/custom-post-type-ui/Otherwise take a look at this article:
https://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-wordpress/You can find lots of result by Google “How to create custom post type WordPress”.
June 3, 2019 at 8:28 am #918666EliaHi Leo,
Seems that we would have to install some plugins. Which is not desired at all.
I’ll wait for Tom’s reply then.
Tom, please let me know if you have any success with excluding the category. If it’s too difficult then let me know
Many thanks
-
AuthorPosts
- You must be logged in to reply to this topic.