Remove Slider Posts from Recent Posts

Hello,

I do not want my slider posts to be seen or accessible to the user unless they are displaying as a slider. I am surprised there is not a check box for that. I was able to exclude the slider category, but the sliders are still showing up in recent posts. I saw an answer that excludes the category using code (https://colorlibsupport.com/t/suppress-slider-on-posts-page/) but that only excludes the sliders from the admin dashboard, not from the user. Please advise.

Thank you,

-Gabe

So I received an email that I cannot reply to from @Movin. Thank you for that but I’m confused as to why I don’t see the answer here. Anyway, the answer is below. Two issues. I do prefer the page solution but I received errors and also do not see an area to write customized fields. I cannot copy this code as is as an alternate solution for obvious reasons. Could you please repost here? Thanks.

@oneillg You can try achieving this by using the attached modified plugin that contains following code but please note if the user accesses post URL directly in the browser then the user can access the post.

function exclude_category( $query ) {
if( of_get_option( 'sparkling_slider_checkbox' ) == 1 && !is_admin() && $query->is_main_query() ){
$slidecat = of_get_option( 'sparkling_slide_categories' );
$query->set( 'cat', '-'.$slidecat );
}
}
add_action( 'pre_get_posts', 'exclude_category' );

You can also use pages for the slider instead of posts by using the solution posted in the following topic.

https://colorlibsupport.com/t/slider-for-pages/#post-33351

Ok nevermind reposting, the html was translated when I posted it.

Hi Gabe,

I hope you are well today and thank you for your question.

The shared custom plugin code is working fine for me so please try using the plugin directly and you can’t reply to my post here because it’s posted on the following topic.

https://colorlibsupport.com/t/suppress-slider-on-posts-page/page/2/

Best Regards,
Movin