Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1437400

    Hi! I am trying to find a solution to a problem. It is regardind side bar widget on this portfolio item (and similar) showing selected portfolio items. I want it to display more than 20 items (20 is max in the regular settings) and I also want them listed alphabetically. Any tips on how I can solve it?

    #1437406

    Hey hannelynne,
    Thanks for your question to modify the newsbox widget (Latest News) you will need to install a child theme, Read about using a Child Theme otherwise your customizations will be lost the next time you update.
    Then in your child theme directory, via FTP, add a directory “widgets” and copy the file from the parent theme to your new directory: \enfold\framework\php\widgets\widget-classes\class-avia-newsbox.php
    Then add this code to your child theme functions.php:

    function custom_avf_widget_loader_widget_classes_newsbox( array $default_widgets )
    {
    	$namespace = '\\aviaFramework\widgets\\';
    
    	// Create a folder widgets in enfold-child:     enfold-child/widgets
    	$path = trailingslashit( get_stylesheet_directory() ) . 'widgets/';
    
    
    	// Replace link to original file with your child theme modified newsbox widget
    	$default_widgets['newsbox'] = array(
    												'class'	=> $namespace . 'avia_newsbox',
    												'file'	=> $path . 'class-avia-newsbox.php'
    											);
    
    	
    	return $default_widgets;
    }
    
    add_filter( 'avf_widget_loader_widget_classes', 'custom_avf_widget_loader_widget_classes_newsbox', 10, 1 );

    Now you are ready to customize your class-avia-newsbox.php file.
    To make the list alphabetical look around line 143 for this: $additional_loop = new WP_Query( "cat={$cat}&posts_per_page={$count}" );
    and change to this: $additional_loop = new WP_Query("orderby=title&order=ASC&cat=".$cat."&posts_per_page=".$count);
    Then to change how many will show look around line 395 for this: for ($i = 1; $i <= 20; $i++ )
    and change to this: for ($i = 1; $i <= 50; $i++ ) now your option will go to 50, adjust to suit.
    Please note that you will need to resave the widget with the new setting before it will work.
    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.

    Best regards,
    Mike

    #1437409

    Hi Mike. Thanks, and great to hear it is possible. But I am not sure I would be able to pull this off myself. Any tips on who can get me the help I need for this?

    Best regards,
    Hanne

    #1437411

    Hi,
    Can you add the child theme ▸ Read about using a Child Theme
    and then include an admin login & FTP access in the Private Content area, I can do the steps above for you.

    Best regards,
    Mike

    #1437413

    Hi Mike :-) . Will give it a go.

    #1437416

    Hi,
    Ok, we will leave this thread open to hear back from you.

    Best regards,
    Mike

    #1437419

    Hi. I think I actually made it. Child theme has been installed and activated and settings imported from Parent theme.

    ftp login details in private content.

    #1437420

    Hi,
    Thanks, I added the customization above but I believe the widget needs to be opened and resaved before it will take effect and I don’t have a site admin login so you will have to try.

    Best regards,
    Mike

    #1437423

    Hi! Did it. So it worked well for the number, it is now set to 50, so showing all we have for now. But isn’t showing alphabetically?

    I see there is (and was already I think) a snippet inn the quick CSS that seems to affect the same side bar. If I remove that code the side bar shows what it does now, plus time, date, who posted it and category too. It is back in place now. Let me know if it should go if it interferes with your coding.

    Kind regards, Hanne

    /*.single-portfolio aside.sidebar.sidebar_right {
    display: none !important;
    }

    .single-portfolio .container .av-content-small.units {
    width: 100% !important;
    }*/

    .image_size_widget span.news-time {
    display: none;
    }
    .image_size_widget strong.news-headline {
    padding-top: 10px;
    }

    #top .avia-post-nav { display: none !important; }

    #1437424

    Hi,
    Thanks for the login, I see that you are using the Latest Portfolio the original customization above was for the Latest News widget, they both use the class-avia-newsbox.php file, but call different lines of code.
    So everything above can stay and we will change around line 154 look for:

    $new_query = array(
    	'posts_per_page'	=> $count,
    	'post_type'		=> $this->avia_post_type
    );

    and change to:

    $new_query = array(
    	'posts_per_page'	=> $count,
    	'post_type'		=> $this->avia_post_type,
    	'orderby'           => 'title',
    	'order'             => 'ASC'
    );

    and around line 169 look for:

    $new_query = array(
    	'posts_per_page'	=> $count,
    	'tax_query'			=> array(
    							array(
    								'taxonomy'	=> $this->avia_term,
    								'field'		=> 'id',
    								'terms'		=> explode( ',', $cat ),
    								'operator'	=> 'IN'
    							)
    						)
    					);

    and change to:

    $new_query = array(
    	'orderby'           => 'title',
    	'order'             => 'ASC',
    	'posts_per_page'	=> $count,
    	'tax_query'			=> array(
    							array(
    								'taxonomy'	=> $this->avia_term,
    								'field'		=> 'id',
    								'terms'		=> explode( ',', $cat ),
    								'operator'	=> 'IN'
    							)
    						)
    					);

    I did this for you and now your Latest Portfolio is alphabetically, I just wanted to explain this for future readers.
    Please clear your browser cache and check.

    Best regards,
    Mike

    #1437428

    Thank you so much for your help, Mike, you’re a star.

    Best regards,
    Hanne

    #1437449

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Side bar widget showing portfolio items’ is closed to new replies.