-
AuthorPosts
-
March 31, 2023 at 1:28 pm #1403116
Hi,
I am looking for a solution to make small changes to the news widget and show a category instead of the time, while using a child theme.
Previous solutions, where the code from the widget could be copied into the child-themes functions.php, produce an error.
Any tipps on how to resolve that?Best regrads,
rawcatApril 2, 2023 at 12:49 pm #1403270Hey cambium.digital,
Thank you for your patience, the file to edit to add the categories to the Latest News widget is:
/wp-content/themes/enfold/framework/php/widgets/widget-classes/class-avia-newsbox.php
on line 219 (v5.5) look for:
echo '<strong class="news-headline">' . get_the_title();
below this add:echo '<br />'; $cats = get_the_category(); foreach ( $cats as $cat ) { echo '<span class = "widget_latest_category">'.$cat->cat_name.'</span> '; }
If you don’t want the date to show place two slashes before the lineecho '<span class="news-time">' . get_the_time( $time_format ) . '</span>';
like this://echo '<span class="news-time">' . get_the_time( $time_format ) . '</span>';
Typically files in the /framework/ directory can not be added to a child theme and copying the function directly to the child theme functions.php was not successful.Best regards,
MikeApril 3, 2023 at 12:35 pm #1403383Hi Mike,
thanks for the reply. Is there a way to make these changes update-proof?
Best
rawcatApril 3, 2023 at 4:49 pm #1403424There is probably a way to do it via child theme, – but because of the dependency of Portfoliobox to Newsbox it is a bit too complicated to give it out quickly. I’ll stay tuned!
…- This reply was modified 1 year, 7 months ago by Guenni007.
April 3, 2023 at 6:04 pm #1403434btw: to set a different source image for the newsbox / portfoliobox you can add that snippet to child-theme functions.php:
( you have to look what index your widgets get )function my_avf_newsbox_image_size( $image_size, array $args, array $instance ){ if( $args['widget_id'] == ( 'portfoliobox-3' || 'newsbox-2' || 'newsbox-4' ) ){ $image_size = 'square'; } return $image_size; } add_filter( 'avf_newsbox_image_size', 'my_avf_newsbox_image_size', 10, 3 );
now for the example above you can now enlarge the thumbnail via quick css:
.news-thumb, .news-thumb img { width: 100px; height: 100px; }
see: https://enfold.webers-webdesign.de/impressum/ at the footer widgets
April 4, 2023 at 9:14 am #1403488@Mike – please generate a Portfolio-Widget – what do you see there ?
April 4, 2023 at 12:28 pm #1403507Hi,
At the bottom you have the code to paste into function.php of your child theme:
/* * Snippet to replace Newsbox widget with your custom Newsbox widget * * @since 5.5 */ 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 );
This is a modified newsbox widget with the categories:
Put this file in folder enfold-child/widgets.
It will replace the original newsbox.
If you need help please provide ftp access and we can do it for you.
Best regards,
GünterApril 4, 2023 at 12:36 pm #1403509yes – perfect – not as amateurish as my approach ;)
I would not have come up with get_the_terms.Thanks alot!
- This reply was modified 1 year, 7 months ago by Guenni007.
April 4, 2023 at 12:41 pm #1403510Awesome, thanks a lot. I will give this a try!
April 4, 2023 at 1:41 pm #1403517Hi,
I uploaded an optimized version:
If you replace line 64:
$this->use_blog_meta_settings = false;
with
$this->use_blog_meta_settings = true;
then theme options blog layout settings are used to show/hide categories and time
Best regards,
GünterApril 4, 2023 at 3:28 pm #1403529April 6, 2023 at 4:41 pm #1403730Hi,
Next release will have improved settings for some widgets in core.
See https://kriesi.at/support/topic/enfold-upcoming-fixes/Best regards,
GünterApril 6, 2023 at 4:43 pm #1403731Awesome! Thank you so much.
PS: This can be closed
April 6, 2023 at 8:58 pm #1403747Great !
-
AuthorPosts
- You must be logged in to reply to this topic.