Use posts_orderby filter and custom fields to do a sticky category post
I want to use the
add_filter('posts_orderby', 'myPostOrder');to implement a sticky post function.
There are a few plugins out there, but they don’t really work. For example WP Category Sticky Posts. If I use this plugin in combination with The Events Calendar sticky posts are listed as well in the widget of “the Events Calendar”, because “Wp Category Sticky Posts” uses the “the_posts” filter.
Hence I want to write my own function. Therefore I want to use a custom field named “sticky-Post”. This custom field is only set “true” if the post is a sticky post. If the post isn’t a sticky post no custom field will be set.
I don’t know how the $orderby should look like in this case. How do I check if a post has the custom field “sticky-Post” and make it the first one to appear in a special category? And furthermore how to sort the other posts by date?
I hope someone can help me!
Thanks in advance :)!
- The topic ‘Use posts_orderby filter and custom fields to do a sticky category post’ is closed to new replies.