badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

How to change footer featured posts logic

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #101720
    gadgsphere
    Participant

    I have a “popular post” banner and “you may missed” banner on one page and when scrolling you can see both banners and the post are identical. I want to change post selection logic in “you may missed” so it does not show the last 4 posts like in “popular post” section

    #101740

    Hi gadgsphere,

    For that, you can create a new category and assign the desired posts to the same. After assigning the posts to the new category you can now choose the same category to show on the ‘You May Missed‘ featured section.

    Please go to ‘Appearance > Customize > Footer Featured Posts’ then check ON ‘Show Posts from Category’ and choose that new category.

    Thanks

    #101741
    gadgsphere
    Participant

    Hi,

    I managed to do it editing php. If someone is trying also to manage this then you shoud go to theme files and footer.php.

    In footer.php you will find section for footer posts. In code you can see comments that I added:
    “Footer “You may missed” posts shows random posts from current week”

    <?php
    /**
     * The template for displaying the footer
     *
     * Contains the closing of the #content div and all content after.
     *
     * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
     *
     * @package NewsCard
     */
    
    ?>
    		<?php global $newscard_settings; ?>
    			</div><!-- row -->
    		</div><!-- .container -->
    	</div><!-- #content .site-content-->
    	<footer id="colophon" class="site-footer" role="contentinfo">
    		<?php if ( $newscard_settings['newscard_footer_featured_posts_hide'] === 0 ) {
    
    			$footer_newscard_cat = absint($newscard_settings['newscard_footer_featured_post_categories']);
    /**
     * Footer "You may missed" posts shows random posts from current week
     * added args are: 'orderby' => 'rand',
    		   'year' => date( 'Y' ),
            	   'week' => strftime( '%U' )
    */
    			$footer_post_type = array(
    				'posts_per_page' => 4,
    				'post__not_in' => get_option('sticky_posts'),
    				'orderby' => 'rand',
    				'year' => date( 'Y' ),
            		'week' => strftime( '%U' ),
    				'post_type' => array(
    					'post'
    				),
    			);
    			if ( $newscard_settings['newscard_footer_featured_latest_post'] == 'category' ) {
    				$footer_post_type['category__in'] = $footer_newscard_cat;
    			}
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.