Tagged: Sticky post
-
AuthorPosts
-
September 16, 2019 at 8:36 pm #1138907
Hello
I’ve selected 2 posts that i would like to have on top for a period of time
I have frontpage with ‘ magazine ‘ element and few categories selected to showso i have All / Category 1 / Category 2 / Category 3
Problem is i cant make two posts from category 1 to be on top all the time [ on all and on category view ]
I’ve selected sticky on post but every time i add new post they are just not sticky and act like normal posts+ Where do i translate ‘ All ” in magazine element ?
September 16, 2019 at 10:54 pm #1138963I’ve found following code but it has a bug .. categories in magazine element are returned empty
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;
}September 17, 2019 at 7:49 pm #1139229any suggestions ?
September 18, 2019 at 9:20 pm #1139707what happened with support here? it was top notch, at least some respond ?
September 19, 2019 at 1:54 pm #1139918Hi,
Sorry for the delay.
The default query will be ignored once you use that filter, which is probably why the category sort no longer works as it should. Where did you add the magazine element?
Best regards,
IsmaelSeptember 19, 2019 at 5:32 pm #1139986hi again
Ive just tested with that code and removed it so now i have default functions file again
on homepage is magazine element [ middle news area ]September 20, 2019 at 1:43 pm #1140211Hi,
Thank you for the update.
We are not really sure if we can find a way around this. You can’t have the sticky posts without using the above filter, which will also alter the default query and affect the category sort. You may need to add another magazine element and apply the filter to it. You can then have the default query on the second element.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.