Viewing 22 posts - 1 through 22 (of 22 total)
  • Author
    Posts
  • #1173643

    Hello and thanks in advance for your help.

    Please go to https://3das.com/gallery/ & click “load more” button in the “3D Exterior Renderings” masonry gallery items. You will see that a 3D rendering is repeating and other renderings are incorrectly being sorted.

    Here is how the renderings should be sorted: https://www.screencast.com/t/Ko7CyK3pU – area in red is where the next rendering should be placed. Here’s the current placement (red box shows the incorrect starting of placement): https://www.screencast.com/t/aOxiUNZv.

    This all started when I wanted to sort my posts manually and I used the script provided by Kriesi at https://kriesi.at/documentation/enfold/blog-post/#toggle-id-26. It seems that this is only happening after “load more” option is used. Turning this off or using pagination seems to be working correctly.

    #1173830

    Hey Brian,

    Sorry for the problem. First off, could you try updating the theme to the latest version (4.7.1) to see if that helps please? https://kriesi.at/documentation/enfold/how-to-install-enfold-theme/#theme-update.

    Best regards,
    Rikard

    #1174646

    Hello Rikard, the theme has been updated to 4.7.1 but the issue is still unresolved.

    #1175199

    Hi,

    Have you cleared your cache and checked in Icognito?

    Best regards,
    Basilis

    #1175215

    Basilis,

    Yes, many times. Did you see different results?

    #1176618

    Hi,

    Thank you for the update.

    Is it working properly when you remove or disable the avia_custom_query_extension function? You should be able to sort the items without adding that function.

    Best regards,
    Ismael

    #1176886

    Removing the script did not work. I tried clearing the cache and updating the page through the editor. Removing the script also rearranges my posts. For example, the https://3das.com/3d-projects/#casestudies section should be listed by cities first but when I remove the script they are in a completely different order.

    The code I use is below for reference:

    // Custom Sort Order
    if(!function_exists('avia_custom_query_extension'))
    {
        function avia_custom_query_extension($query, $params)
        {
            global $avia_config;
            if(!empty($avia_config['avia_custom_query_options']['order']))
            {
                $query['order'] = $avia_config['avia_custom_query_options']['order'];
            }
    
            if(!empty($avia_config['avia_custom_query_options']['orderby']))
            {
                $query['orderby'] = $avia_config['avia_custom_query_options']['orderby'];
            }
    
            unset($avia_config['avia_custom_query_options']);
    
            return $query;
        }
    
        add_filter('avia_masonry_entries_query', 'avia_custom_query_extension', 10, 2);
        add_filter('avia_post_grid_query', 'avia_custom_query_extension', 10, 2);
        add_filter('avia_post_slide_query', 'avia_custom_query_extension', 10, 2);
        add_filter('avia_blog_post_query', 'avia_custom_query_extension', 10, 2);
        add_filter('avf_magazine_entries_query', 'avia_custom_query_extension', 10, 2);
    
        add_filter('avf_template_builder_shortcode_elements','avia_custom_query_options', 10, 1);
        function avia_custom_query_options($elements)
        {
            $allowed_elements = array('av_blog','av_masonry_entries','av_postslider','av_portfolio','av_magazine');
    
            if(isset($_POST['params']['allowed']) && in_array($_POST['params']['allowed'], $allowed_elements))
            {
                $elements[] = array(
                    "name" => __("Custom Query Orderby",'avia_framework' ),
                    "desc" => __("Set a custom query orderby value",'avia_framework' ),
                    "id"   => "orderby",
                    "type" 	=> "select",
                    "std" 	=> "",
                    "subtype" => array(
                        __('Default Order',  'avia_framework' ) =>'',
                        __('Title',  'avia_framework' ) =>'title',
                        __('Random',  'avia_framework' ) =>'rand',
                        __('Date',  'avia_framework' ) =>'date',
                        __('Author',  'avia_framework' ) =>'author',
                        __('Name (Post Slug)',  'avia_framework' ) =>'name',
                        __('Modified',  'avia_framework' ) =>'modified',
                        __('Comment Count',  'avia_framework' ) =>'comment_count',
                        __('Page Order',  'avia_framework' ) =>'menu_order')
                );
    
                $elements[] = array(
                    "name" => __("Custom Query Order",'avia_framework' ),
                    "desc" => __("Set a custom query order",'avia_framework' ),
                    "id"   => "order",
                    "type" 	=> "select",
                    "std" 	=> "",
                    "subtype" => array(
                        __('Default Order',  'avia_framework' ) =>'',
                        __('Ascending Order',  'avia_framework' ) =>'ASC',
                        __('Descending Order',  'avia_framework' ) =>'DESC'));
            }
    
            return $elements;
        }
    
        add_filter('avf_template_builder_shortcode_meta', 'avia_custom_query_add_query_params_to_config', 10, 4);
        function avia_custom_query_add_query_params_to_config($meta, $atts, $content, $shortcodename)
        {
            global $avia_config;
            if(empty($avia_config['avia_custom_query_options'])) $avia_config['avia_custom_query_options'] = array();
    
            if(!empty($atts['order']))
            {
                $avia_config['avia_custom_query_options']['order'] = $atts['order'];
            }
    
            if(!empty($atts['orderby']))
            {
                $avia_config['avia_custom_query_options']['orderby'] = $atts['orderby'];
            }
    
            return $meta;
        }
    }
    
    #1177961

    Hi,

    Thank you for the update.

    Did you reset the order or sorting after removing the snippet? Please post the login details in the private field so that we can check the issue further.

    Best regards,
    Ismael

    #1178193

    Ismael,

    Thank you. Not sure what you exactly mean by reset but I did try to update the page after removing the code w/o sorting first & then updating after sorting a gallery item.

    #1178593

    Hi,

    Thank you for the update.

    It’s not working properly because of the Post Types Order plugin. Somehow, the plugin alters the query of the gallery causing duplicate items.

    Best regards,
    Ismael

    #1178690

    Ismael,

    Thank you for looking into this. The reason I used the plugin was due to the directions below not being clear on what to do after you have installed the code & saved the template page(s). Can you tell me how I can sort my posts after I configure the order/orderby settings?

    Directions from https://kriesi.at/documentation/enfold/blog-post/#toggle-id-26:

    How to add an order/orderby option to the blog/post slider/portfolio/masonry grid element
    Some users asked us how they can set a different order for their blog/post slider/portfolio/masonry grid elements. The filter solution here: https://kriesi.at/documentation/enfold/change-the-sort-order-of-portfolio-elements/ is not flexible because it affects all elements and all custom queries. Since Enfold 2.7.1 it’s possible to add some custom order/orderby options to the blog/post slider/portfolio/masonry grid settings which enable you to change the sort order for each element independently. Insert the code below into the child theme functions.php file and save the file. Then go to the blog/post slider/portfolio/masonry grid element settings screen, scroll to the bottom of the options window and configure the order/orderby settings. Then save the template and page and the posts should be displayed based on the new sort order.

    Attention – if you use the “Random” sort option, do not use it in combination with the “pagination” setting. Otherwise, you risk that the user just sees the same posts over and over again because WordPress doesn’t know which posts were used on the other pages.

    #1179265

    Hi,

    Directions from https://kriesi.at/documentation/enfold/blog-post/#toggle-id-26:

    It’s still working on our end, so you can enable it back. After the activation, edit the masonry element, open the Sorting toggle, then set the Order by and Display Order settings as you prefer. If you want to sort them manually, try to set the Order by settings to Page Order. You will then be able to use the Page Attributes > Order field to adjust the order of the items in the grid

    // https://make.wordpress.org/support/user-manual/content/pages/page-attributes/

    This requires you enable the Page Attributes meta box for posts or custom post types.

    // https://wordpress.stackexchange.com/questions/35221/how-to-get-template-drop-down-menu-in-page-attributes-of-custom-post-type

    To change the arguments of an existing post type, please refer to this thread.

    // https://wordpress.stackexchange.com/a/230313
    // https://developer.wordpress.org/reference/hooks/register_post_type_args/

    Best regards,
    Ismael

    #1179607

    OK, I understand the page order but I’ll need some coaching on creating the post orders as I typically don’t do much programming.

    <?php
    /*
    Template Name: My custom layout
    Template Post Type: post, page, product
    */

    and then add:
    'supports' => array('title', 'page-attributes'),
    I did this in the single.php file & the post attributes menu does show up on the blog pages but without the page order. If I select “My custom layout”, it breaks the page.

    Ultimately I would like to add the code in my child theme. What steps am I missing and do I add a single.php in my child theme with only the code I am adding in (like I do with functions.php)?

    • This reply was modified 4 years, 10 months ago by brianzajac.
    #1180191

    Hi,

    Thank you for following up.

    Did you replace Masonry with the Masonry Gallery element? You won’t be needing the sorting options because you can just manually drag and drop the images to change their position in the gallery.

    We don’t need to create a template. We enabled the page-attributes metabox only to get access to the Order field, but since you’re using the Masonry Gallery now, you will no longer need it.

    Best regards,
    Ismael

    #1180367

    Ismael,

    I have two main areas where I use the masonry elements:

    https://3das.com/3d-projects/ – based off post order using masonry
    https://3das.com/gallery/ – based off masonry gallery.

    Both are being affected by the plugin & the code snippet described above and I will need to get the order field on my posts. Where should I put 'supports' => array('title', 'page-attributes'), in single.php? Are there more steps I need to take?

    #1180849

    Hi,

    You don’t have to add that code specifically. You have to use the register_post_type_args filter to change the default arguments of the post or portfolio post types and enable the page attributes.

    Example: https://developer.wordpress.org/reference/hooks/register_post_type_args/#user-contributed-notes

    
    function avf_register_post_type_args($args, $post_type){
    
        if ($post_type == 'portfolio' || $post_type == 'post'){
            $args['supports'] = 'page-attributes';
        }
    
        return $args;
    }
    add_filter('register_post_type_args', 'avf_register_post_type_args', 10, 2);
    

    This will enable the Page Attributes meta box for portfolio and post items.

    Best regards,
    Ismael

    #1181070

    Thank you, I have removed:

    'supports' => array('title', 'page-attributes')

    and have the “Custom Sort Order” code into functions.php (Enfold Child) & the avf_register_post_type_args code listed above single.php (Enfold).

    I don’t see any changes & now I don’t see any post attributes listed. Please list the PHP files I need to add this code to for any Enfold posts + any other code I need to add in.

    For reference, here is the code for single.php:

    <?php
    /*
    Template Post Type: post, page, product
    */
    	if ( !defined('ABSPATH') ){ die(); }
    	
    	global $avia_config;
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */
    	 get_header();
    
    	$title  = __('Blog - Latest News', 'avia_framework'); //default blog title
    	$t_link = home_url('/');
    	$t_sub = "";
    
    	if(avia_get_option('frontpage') && $new = avia_get_option('blogpage'))
    	{
    		$title 	= get_the_title($new); //if the blog is attached to a page use this title
    		$t_link = get_permalink($new);
    		$t_sub =  avia_post_meta($new, 'subtitle');
    	}
    
    	if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title(array('heading'=>'strong', 'title' => $title, 'link' => $t_link, 'subtitle' => $t_sub));
    	
    	do_action( 'ava_after_main_title' );
    
    //added for ordering attribute for post pages - BZ
    function avf_register_post_type_args($args, $post_type){
    
        if ($post_type == 'portfolio' || $post_type == 'post'){
            $args['supports'] = 'page-attributes';
        }
    
        return $args;
    }
    add_filter('register_post_type_args', 'avf_register_post_type_args', 10, 2); //added for ordering attribute for post pages - BZ
    
    ?>
    
    		<div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>
    
    			<div class='container template-blog template-single-blog '>
    
    				<main class='content units <?php avia_layout_class( 'content' ); ?> <?php echo avia_blog_class_string(); ?>' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>>
    
                        <?php
                        /* Run the loop to output the posts.
                        * If you want to overload this in a child theme then include a file
                        * called loop-index.php and that will be used instead.
                        *
                        */
                            get_template_part( 'includes/loop', 'index' );
    						
    						$blog_disabled = ( avia_get_option('disable_blog') == 'disable_blog' ) ? true : false;
    						
    						if(!$blog_disabled)
    						{
    	                        //show related posts based on tags if there are any
    	                        get_template_part( 'includes/related-posts');
    	
    	                        //wordpress function that loads the comments template "comments.php"
    	                        comments_template();
    						}
                        ?>
    
    				<!--end content-->
    				</main>
    
    				<?php
    				$avia_config['currently_viewing'] = "blog";
    				//get the sidebar
    				get_sidebar();
    
    				?>
    
    			</div><!--end container-->
    
    		</div><!-- close default .container_wrap element -->
    
    <?php 
    		get_footer();
    #1181614

    Hi,

    We moved the filter in the child theme’s functions.php file to enable the page attributes box. We also edited the 3d-projects page and set the Order by settings to Page Order and the Display order to Ascending. The items are now sorted based on the value of the Order field.

    Please don’t forget to remove or purge the cache before checking the page.

    Thank you for your patience.

    Best regards,
    Ismael

    #1181901

    Thank you Ismael. All seems to be working now.

    #1182442

    Hi,

    Great, I’m glad that you got things working and that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #1182592

    Nope, I should be good. Please close this topic.

    #1182693

    Hi,

    Thanks for letting us know, I’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 22 posts - 1 through 22 (of 22 total)
  • The topic ‘Sorting Masonry Gallery Items Incorrectly After "Load More"’ is closed to new replies.