Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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 Johnston

    #808805

    Hey 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_post

    Best regards,
    Ismael

    #808955

    Thanks 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?

    #810155

    Hi,

    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,
    Ismael

    #811505

    Thanks 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 6 years, 9 months ago by trevorjohnston. Reason: Corrected error message
    #812889

    Hi,

    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,
    Ismael

    #813375

    Hi,
    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,
    Trevor

    #813703

    Hi,

    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,
    Ismael

    #813796

    Hi,
    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,
    Trevor

    #814316

    Hi,

    We added the code again via FTP and it is working. Please check.

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.