Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1018195

    Hi is it possible to have “Sticky” or “pinned” news articles (posts) that can be at the top of the Magazine element? Articles that can hang around longer and that don’t get pushed down by new articles that have been posted.

    Thanks

    #1019102

    Hey johnosjourney,

    Try adding this php code in functions.php:

    add_filter('avf_magazine_entries_query', 'avf_magazine_entries_query_sticky', 10, 2);
    function avf_magazine_entries_query_sticky($query, $params) {	
    	$include = array();
    	$sticky = get_option( 'sticky_posts' );
    
    	$args = array(
    		'taxonomy' => $params['taxonomy'],
    		'post__not_in' => $sticky,
    	);
    	$posts = get_posts( $args );
    
    	foreach($posts as $post) {
    		$include[] = $post->ID;
    	}
    
    	$include = array_merge($sticky, $include);
    
    	$query['post__in'] = $include;
    	$query['orderby'] = 'post__in'; // sort items based on the post__in value
    	return $query;
    }

    Let us know if this helps.

    Best regards,
    Nikko

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