-
AuthorPosts
-
March 17, 2024 at 12:05 pm #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?
March 17, 2024 at 1:28 pm #1437406Hey 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,
MikeMarch 17, 2024 at 3:20 pm #1437409Hi 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,
HanneMarch 17, 2024 at 4:10 pm #1437411Hi,
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,
MikeMarch 17, 2024 at 4:27 pm #1437413Hi Mike :-) . Will give it a go.
March 17, 2024 at 5:28 pm #1437416March 17, 2024 at 6:22 pm #1437419Hi. 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.
March 17, 2024 at 7:20 pm #1437420Hi,
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,
MikeMarch 17, 2024 at 7:34 pm #1437423Hi! 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; }
March 17, 2024 at 8:37 pm #1437424Hi,
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,
MikeMarch 17, 2024 at 10:26 pm #1437428Thank you so much for your help, Mike, you’re a star.
Best regards,
HanneMarch 18, 2024 at 11:01 am #1437449Hi,
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 -
AuthorPosts
- The topic ‘Side bar widget showing portfolio items’ is closed to new replies.