-
AuthorPosts
-
June 12, 2017 at 11:15 pm #807143
Hi,
First off, please forgive me if I am using the wrong terminology. Here’s my problem though: If you click on the title of any of the 28 illustration “thumbnails” on my sites home page, it opens up a portolio detail page for that specific image. On each side of the full page are arrows with small circular thumbnail images so you can advance, or reverse to the next or previous portfolio details page. The problem is that the detail pages appear in the order the portfolio items were uploaded, not in the order they appear on my homepage or the order I specified for each image. How can I fix that so the portfolio detail pages load in the same order as the portfolio items appear on my homepage (without sorting the homepage images by upload date)?
Thanks,
Trevor JohnstonJune 16, 2017 at 5:17 am #808805Hey trevorjohnston,
Thank you for using Enfold.
The “avia_post_nav” function is based on the native function get_previous_post and get_next_post. Unfortunately, it can only fetch entries that is adjacent to the current post.
// https://codex.wordpress.org/Function_Reference/get_next_post
// https://codex.wordpress.org/Function_Reference/get_previous_postBest regards,
IsmaelJune 16, 2017 at 12:52 pm #808955Thanks for the response. Could you please translate for the less technically savvy, i.e. me? I’m not at all clear what those links are saying. By “adjacent to the current post,” are you referring to post date? I would like them viewed according to Order set in Post Attributes. Is that not possible?
June 20, 2017 at 6:04 am #810155Hi,
Yes, the posts filter is based on post date. It cannot filter posts based on the “Order” attribute without adjusting the posts query. Please try this code in the functions.php file.
function avf_previous_post_where() { global $post, $wpdb; return $wpdb->prepare( "WHERE p.menu_order < %s AND p.post_type = %s AND p.post_status = 'publish'", $post->menu_order, $post->post_type); } add_filter( 'get_previous_post_where', 'avf_previous_post_where' ); function avf_next_post_where() { global $post, $wpdb; return $wpdb->prepare( "WHERE p.menu_order > %s AND p.post_type = %s AND p.post_status = 'publish'", $post->menu_order, $post->post_type); } add_filter( 'get_next_post_where', 'avf_next_post_where' ); function avf_previous_post_sort() { return "ORDER BY p.menu_order desc LIMIT 1"; } add_filter( 'get_previous_post_sort', 'avf_previous_post_sort' ); function avf_next_post_sort() { return "ORDER BY p.menu_order asc LIMIT 1"; } add_filter( 'get_next_post_sort', 'avf_next_post_sort' );
Based on:
// https://1fix.io/blog/2014/09/09/get-right-previous_post_link-when-order-posts-by-menu_order/Best regards,
IsmaelJune 22, 2017 at 1:33 pm #811505Thanks Ismael. I added that code to the functions.php file and received the following error message:
Parse error: syntax error, unexpected ‘<‘ in D:\Hosting\7270199\html\wp-content\themes\enfold-child\functions.php on line 320- This reply was modified 7 years, 5 months ago by trevorjohnston. Reason: Corrected error message
June 26, 2017 at 6:30 am #812889Hi,
Please copy the code directly from this forum, not from your email. The quotes inside the code are probably converted to html characters. Anyway, we added the code for you. Please remove browser cache before checking the page.
Best regards,
IsmaelJune 27, 2017 at 12:37 pm #813375Hi,
I appreciate you inputting the code. Unfortunately, it’s still not operating in post order (Post Attributes: Order). I deleted cache, refreshed multiple times and I’m not sure what order it’s displaying in, but it isn’t post order as I’ve specified in Post Attributes.
Thanks,
TrevorJune 28, 2017 at 7:38 am #813703Hi,
Did you remove the code? I can’t find it in the functions.php file. We might break the site if we add duplicate functions. Please add the filters back then remove the cache or hard refresh before checking the page. Please give us links to the portfolio items that are supposed to be in order.
Best regards,
IsmaelJune 28, 2017 at 1:35 pm #813796Hi,
No, I didn’t open the functions.php file at all. Had you added the code to the functions.php in the child theme folder (which is what I am using)? The portfolio items should be in the same order they appear on the main page, moving left to right across each row.
Thanks,
TrevorJune 29, 2017 at 10:17 am #814316 -
AuthorPosts
- You must be logged in to reply to this topic.