-
AuthorPosts
-
January 9, 2020 at 10:41 pm #1171998
Hi I’m building a site for a client who sells antiques.
I am using the portfolio post to showcase her inventory.
People can make an enquiry to buy an item. (no ecommerce)
Once the item is sold we want to hide the portfolio post from the front end but still have it available should an old link/search term still link to it.
I have created a Portfolio category called Archive and the portfolio grids are set up NOT to display the category Archive. All good so far.
The problem comes with the next/previous buttons to the left and right of the screen. If a user uses these they scroll through all of the portfolio posts across all portfolio categories.
Is there a way to stop these buttons calling portfolio post with the archive category or only show posts from particular/selected categories?
Any ideas welcome.
Best
Dominic
January 10, 2020 at 2:15 am #1172039Managed to use this. It’s not exactly what I want but its quite good. It shows all posts from same category rather than excluding just one. Let me know if anyone has any other thoughts.
D
/* make previous-next buttons stay within the relevant portfolio category (multiple portfolios) */ add_filter( 'avia_post_nav_entries', 'enfold_customization_postnav', 10, 2); function enfold_customization_postnav($entries, $settings) { if($settings['type'] == 'portfolio') { $settings['same_category'] = true; $entries['prev'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']); $entries['next'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']); } return $entries; }
January 11, 2020 at 3:32 am #1172330Hi domchocolate,
Thanks for posting the solution that worked for you, here’s some suggestion since avia_post_nav_entries is deprecated, please use avf_post_nav_entries in version 4.5.6 and above. Also I think $entries[‘prev’] and $entries[‘next’] isn’t needed, here’s another version of your code which works similarly:
add_filter( 'avf_post_nav_entries', 'enfold_customization_postnav', 10, 2); function enfold_customization_postnav($entries, $settings) { if($settings['type'] == 'portfolio') { $settings['same_category'] = true; } return $entries; }
Best regards,
NikkoJanuary 13, 2020 at 12:35 pm #1172730Hi I tried that code and it didn’t work. I am using Version: 4.6.3.1 of Enfold. I reverted back to old code.
Any thoughts?
January 14, 2020 at 5:35 pm #1173479Hi domchocolate,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaJanuary 14, 2020 at 5:52 pm #1173504Hi domchocolate,
I apologize for the mistake, it should be this code:
add_filter( 'avf_post_nav_settings', 'enfold_post_nav_settings', 10, 2); function enfold_post_nav_settings($settings) { if($settings['type'] == 'portfolio') { $settings['same_category'] = true; } return $settings; }
Best regards,
NikkoJanuary 16, 2020 at 2:00 pm #1174947That’s done it – thanks Nikko!
January 16, 2020 at 2:06 pm #1174950 -
AuthorPosts
- The topic ‘Previous/Next Portfolio post buttons’ is closed to new replies.