Home › Forums › Calendar Products › Events Calendar PRO › Sticky not working
- This topic has 3 replies, 2 voices, and was last updated 6 years, 11 months ago by skynet.
-
AuthorPosts
-
May 11, 2017 at 11:36 pm #1282807skynetParticipant
Hello,
We have set an event sticky on the month view, but it not showing first on the month.
Also how can we get a sticky event via query so we will just show a sticky event to our home page??
We have try a below PHP code but not working.
$sticky = get_option( ‘sticky_posts’ );
$args = array( ‘numberposts’ => ‘2’,’post_status’ => ‘publish’, ‘post_type’ => ‘tribe_events’,’post__in’ => $sticky, ‘ignore_sticky_posts’ => 1);
$sticky_posts = wp_get_recent_posts( $args );May 12, 2017 at 6:13 am #1282893NicoMemberHi there @skynet,
Thanks for getting in touch with us! I can help you here 🙂
We have set an event sticky on the month view, but it not showing first on the month.
This option should ensure the event is shown in month view when there are many events and some of them don’t get into the list. It doesn’t mean it will show first!
Also how can we get a sticky event via query so we will just show a sticky event to our home page?
This is not easily doable as ‘Sticky in month view’ relies on the ‘menu_order’ post value (a column in the posts table) and not the same ‘sticky’ value to make a post/page sticky. A workaround is to query events and order them by ‘menu_order’ this will make stickies come first, so following this logic you could do something like this:
// Grab events by menu_order this will make 'stickies in month view' go first
$events = tribe_get_events( array(
'orderby' => 'menu_order'
) );foreach ( $events as $post ) {
setup_postdata( $post );// if this is true then we are out of 'sticky' in month view events
if ( $post->menu_order != -1 ) break;// this is a sticky in month view let's print it
echo $post->post_title . '<br>';}
Please let me know if this helps,
Best,
NicoJune 3, 2017 at 9:35 am #1292861Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Sticky not working’ is closed to new replies.