• Hello!

    I am using the sparkling’s own widget “popular posts” and noticed that in order to fit the small picture on the sidebar perfectly, the picture in the post must be 500×500.

    Is there any way that I can make smaller /bigger pictures scale automatically to the widget since it looks a bit odd if the picture in the post doesn’t fit the widget’s small picture perfectly. (As is the case in some of my most popular posts at the moment on my site https://omavaraisuushaaste.com/)

    And also, is there a way that I can add a picture as just an “blog post picture”, so it would show only as the “blog picture” in e.g. most popular posts widget, but not in that particular blog post itself. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @omavaraisuushaaste,

    Thank you for your question.

    You have to develop custom code to achieve this as developed in the following topic for Activello Recent Posts Widget.

    https://colorlib.com/wp/forums/topic/wp-post-image-thumbnail-square-shape/#post-88353

    Best regards,
    Vinod Dalvi

    Thread Starter omavaraisuushaaste

    (@omavaraisuushaaste)

    Hey, thanks for the answer! Do you have any advice for creating the code since I’m no expert creating the code. The Activello post looks like this.

    /**
    * activello Top Posts Widget
    * activello Theme
    */
    class custom_activello_recent_posts extends WP_Widget
    {
    function __construct(){

    $widget_ops = array(‘classname’ => ‘activello-recent-posts’,’description’ => esc_html__( “Activello recent posts widget with thumbnails”, ‘activello’) );
    parent::__construct(‘custom_activello_recent_posts’, esc_html__(‘Activello Recent Posts Widget’,’activello’), $widget_ops);
    }

    function widget($args , $instance) {
    extract($args);
    $title = isset($instance[‘title’]) ? esc_html( $instance[‘title’] ) : esc_html__(‘recent Posts’, ‘activello’);
    $limit = isset($instance[‘limit’]) ? esc_html( $instance[‘limit’] ) : 5;

    echo $before_widget;
    echo $before_title;
    echo $title;
    echo $after_title;

    /**
    * Widget Content
    */
    ?>

    <!– recent posts –>
    <div class=”recent-posts-wrapper”>

    <?php

    $featured_args = array(
    ‘posts_per_page’ => $limit,
    ‘ignore_sticky_posts’ => 1
    );

    $featured_query = new WP_Query($featured_args);

    /**
    * Check if zilla likes plugin exists
    */
    if($featured_query->have_posts()) : while($featured_query->have_posts()) : $featured_query->the_post();

    ?>

    <?php if(get_the_content() != ”) : ?>

    <!– post –>
    <div class=”post”>

    <!– image –>
    <div class=”post-image <?php echo get_post_format(); ?>”>

    “><?php
    if(get_post_format() != ‘quote’) {
    echo get_the_post_thumbnail(get_the_ID() , ‘full’);
    }
    ?>

    </div> <!– end post image –>

    <!– content –>
    <div class=”post-content”>

    “><?php echo get_the_title(); ?>
    <span class=”date”>- <?php echo get_the_date(‘d M , Y’); ?></span>

    </div><!– end content –>
    </div><!– end post –>

    <?php endif; ?>

    <?php

    endwhile; endif; wp_reset_query();

    ?>

    </div> <!– end posts wrapper –>

    <?php

    echo $after_widget;
    }

    function form($instance) {

    if(!isset($instance[‘title’])) $instance[‘title’] = esc_html__(‘recent Posts’, ‘activello’);
    if(!isset($instance[‘limit’])) $instance[‘limit’] = 5;

    ?>

    <p><label for=”<?php echo $this->get_field_id(‘title’); ?>”><?php esc_html_e(‘Title’, ‘activello’) ?></label>

    <input type=”text” value=”<?php echo esc_html($instance[‘title’]); ?>”
    name=”<?php echo $this->get_field_name(‘title’); ?>”
    id=”<?php $this->get_field_id(‘title’); ?>”
    class=”widefat” />
    </p>

    <p><label for=”<?php echo $this->get_field_id(‘limit’); ?>”><?php esc_html_e(‘Limit Posts Number’, ‘activello’) ?></label>

    <input type=”number” value=”<?php echo esc_html($instance[‘limit’]); ?>”
    name=”<?php echo $this->get_field_name(‘limit’); ?>”
    id=”<?php $this->get_field_id(‘limit’); ?>”
    class=”widefat” />
    <p>

    <?php
    }

    /**
    * Sanitize widget form values as they are saved.
    *
    * @see WP_Widget::update()
    *
    * @param array $new_instance Values just sent to be saved.
    * @param array $old_instance Previously saved values from database.
    *
    * @return array Updated safe values to be saved.
    */
    public function update( $new_instance, $old_instance ) {
    $instance = array();
    $instance[‘title’] = ( ! empty( $new_instance[‘title’] ) ) ? esc_html( $new_instance[‘title’] ) : ”;
    $instance[‘limit’] = ( ! empty( $new_instance[‘limit’] ) && is_numeric( $new_instance[‘limit’] ) ) ? esc_html( $new_instance[‘limit’] ) : ”;

    return $instance;
    }
    }

    function custom_activello_widgets_init(){
    unregister_widget( ‘activello_recent_posts’ );
    register_widget( ‘custom_activello_recent_posts’ );
    }
    add_action( ‘widgets_init’, ‘custom_activello_widgets_init’, 99 );

    Should I just replace the activello ′spots with the word “sparkling” and it should work or do I need more drastic modification of the code? Thanks!

    Should I just replace the activello ′spots with the word “sparkling” and it should work or do I need more drastic modification of the code?

    You need drastic modification of the code. If you are not a developer then you can consider hiring a developer to develop it for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Blog post picture and sparkling popular post widget’ is closed to new replies.