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

    #1403270

    Hey 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> ';
    }

    Enfold_Support_789.jpeg
    Enfold_Support_791.jpeg
    If you don’t want the date to show place two slashes before the line echo '<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,
    Mike

    #1403383

    Hi Mike,

    thanks for the reply. Is there a way to make these changes update-proof?

    Best
    rawcat

    #1403424

    There 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.
    #1403434

    btw: 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

    #1403488

    @Mike – please generate a Portfolio-Widget – what do you see there ?

    #1403507

    Hi,

    See file :
    https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/Widgets/avf_widget_loader_widget_classes.php

    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:

    https://github.com/KriesiMedia/enfold-library/blob/master/customizations/widgets/class-avia-newsbox.php

    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ünter

    #1403509

    yes – 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.
    #1403510

    Awesome, thanks a lot. I will give this a try!

    #1403517

    Hi,

    I uploaded an optimized version:

    https://github.com/KriesiMedia/enfold-library/blob/master/customizations/widgets/class-avia-newsbox.php

    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ünter

    #1403529

    wow

    #1403730

    Hi,

    Next release will have improved settings for some widgets in core.
    See https://kriesi.at/support/topic/enfold-upcoming-fixes/

    Best regards,
    Günter

    #1403731

    Awesome! Thank you so much.

    PS: This can be closed

    #1403747

    Great !

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