Viewing 6 replies - 1 through 6 (of 6 total)
  • Leo

    (@leohsiang)

    Hi there,

    For the first screenshot, it looks like you’ve added lots of <br> tag that’s causing the issue:
    https://www.screencast.com/t/96xRob5ir

    For the Related Article margin issue, it’s because this CSS you’ve added:

    .related-posts h2 {
    	margin-bottom: 0px;
    	font-size: 1.3em;
    	line-height: 2px;
    	font-weight: normal;
    }

    I believe the second issue is due to the break tag as well.

    The sidebar widgets are mostly built with custom HTML and CSS so the theme itself doesn’t realy have control over it at all.

    Thread Starter Tubaa

    (@tubaa)

    Hi,
    I didn’t add any ” <br> ” codes. And I didn’t use a css for the h2 tag, how can I fix them , here the codes which I have used

    Thank you

    ------related-posts-template.php
    
    <?php if (!empty($related_posts)) { ?>
        <div class="related-posts">
            <h2 class="widget-title"><?php _e('Related Article', 'generatepress'); ?></h2>
    
            <ul class="related-posts-list">
                <?php
                foreach ($related_posts as $post) {
                    setup_postdata($post);
                ?>
                <li><font face="Calibri" size="3" color="#666666"><?php echo (int) get_post_meta(get_the_ID(), 'post_views_count', true) . ' Views';  ?></font>
                    <a class="title" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                        <?php if (has_post_thumbnail()) { ?>
                        <div class="thumb">
                            <?php echo get_the_post_thumbnail(null, 'medium', array('alt' => the_title_attribute(array('echo' => false)))); ?>
                        </div>
                        <?php } ?>
                        <h4><?php the_title(); ?><?php if ( has_post_thumbnail()  ) {
    		  the_post_thumbnail('large');
    		} else {		  $post_image_link = catch_that_image();			if ( $post_image_link ) {				echo '<div class="post-thumbnail-wrap"><a href="' . esc_url( get_permalink() ) . '" class="post-thumbnail" rel="bookmark">';				echo '<img width="650" height="366" src="' . esc_attr( $post_image_link ) . '" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="' . esc_attr( get_the_title() ) . '"title="' . esc_attr( get_the_title() ) .'">';			echo '</a></div>';			}	}   ?></h4>
                    </a>
                </li>
                <?php } ?>
            </ul>
            <div class="clearfix"></div>
        </div>
    <?php
    }
    
    ----  function.php
    
    // relatedpost
    function wcr_related_posts($args = array()) {
        global $post;
    
        // default args
        $args = wp_parse_args($args, array(
            'post_id' => !empty($post) ? $post->ID : '',
            'taxonomy' => 'category',
            'limit' => 4,
            'post_type' => !empty($post) ? $post->post_type : 'post',
            'orderby' => 'rand',
            'order' => 'DESC'
        ));
    
        // check taxonomy
        if (!taxonomy_exists($args['taxonomy'])) {
            return;
        }
    
        // post taxonomies
        $taxonomies = wp_get_post_terms($args['post_id'], $args['taxonomy'], array('fields' => 'ids'));
    
        if (empty($taxonomies)) {
            return;
        }
    
        // query
        $related_posts = get_posts(array(
            'post__not_in' => (array) $args['post_id'],
            'post_type' => $args['post_type'],
            'tax_query' => array(
                array(
                    'taxonomy' => $args['taxonomy'],
                    'field' => 'term_id',
                    'terms' => $taxonomies
                ),
            ),
            'posts_per_page' => $args['limit'],
            'orderby' => $args['orderby'],
            'order' => $args['order']
        ));
    
        include( locate_template('related-posts-template.php', false, false) );
    
        wp_reset_postdata();
    }
    // relatedpost
    
    -------rand-post.php
    
    <div class="related-posts">
            <h2 class="widget-title"><?php _e('Trend Article', 'generatepress'); ?></h2>
    <?php
    $popular_posts_args = array(
        'posts_per_page' => 3,
        'meta_key' => 'post_views_count',
        'orderby' => 'rand',
        'order' => 'DESC'
    );
     
    $popular_posts_loop = new WP_Query($popular_posts_args);
     
    while ($popular_posts_loop->have_posts()):
        $popular_posts_loop->the_post();
    ?>
     <!-- Post Title -->
     <font face="Calibri" size="3" color="#666666"><?php echo (int) get_post_meta(get_the_ID(), 'post_views_count', true) . ' Views';  ?></font>
     <a href="<?php the_permalink(); ?>"> <?php the_title(); ?><?php if ( has_post_thumbnail()  ) {
    		  the_post_thumbnail('large');} else {		  $post_image_link = catch_that_image();			if ( $post_image_link ) {				echo '<div class="post-thumbnail-wrap"><a href="' . esc_url( get_permalink() ) . '" class="post-thumbnail" rel="bookmark">';				echo '<img width="650" height="366" src="' . esc_attr( $post_image_link ) . '" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="' . esc_attr( get_the_title() ) . '"title="' . esc_attr( get_the_title() ) .'">';			echo '</a></div>';			}	}   ?></a> 
     <!-- Post Image  -->
     <?php the_post_thumbnail('delicious-recent-thumbnails'); ?>
    <?php
    endwhile;
    wp_reset_query();
    ?>
    Thread Starter Tubaa

    (@tubaa)

    Here Css
    , how can I fix them ?
    Thank you

    .related-posts h2 {
    	margin-bottom: 0px;
    	font-size: 1.3em;
    	line-height: 2px;
    	font-weight: normal;
    }
    
    .related-posts li {
    	width: 97%;
    	float: left;
    	list-style: none;
    	margin-bottom: 0px;
    	margin-right: 0%;
      margin-left: 0%;
    	padding: 0;
    }
    
    .related-posts h4 {
    	clear: none;
    	font-size: 17px;
    	font-weight: normal;
    	line-height: 27px;
    	margin: 0;
    	overflow: hidden;
    }
    Leo

    (@leohsiang)

    It’s just what I’m seeing in the HTML:
    https://www.screencast.com/t/96xRob5ir

    Unfortunately, we cannot help with custom solutions in the free theme support forum here as it’s not related to the theme.

    Thanks for your understanding.

    Thread Starter Tubaa

    (@tubaa)

    Ok. Thank you Leo. Problem Resolved.

    Leo

    (@leohsiang)

    Glad to hear ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sidebar -Widget Issue’ is closed to new replies.