How to remove MULTIPLE posts from ‘Top Posts’ widget?
-
Hi there,
Quick question. I’m sure it’s trivial, I’m just not that fluent in PHP yet.
I understand the following code is the suggested way to remove a specific post (via its post_ID) from the ‘Top Posts’ widget.
Jetpack: remove a post from the Top Posts Widgetfunction jeherve_remove_post_top_posts( $posts, $post_ids, $count ) { foreach ( $posts as $k => $post ) { // Replace 1215 by the ID of the Post you want to remove if ( '1215' == $post['post_id'] ) { unset( $posts[$k] ); } } return $posts; } add_filter( 'jetpack_widget_get_top_posts', 'jeherve_remove_post_top_posts', 10, 3 );However, how would I remove multiple posts? Do I have to use multiple ‘if’s? Or can I somehow use an OR operator or commas? Or something else entirely?
I haven’t seen anywhere where this is touched on. Anyway, thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘How to remove MULTIPLE posts from ‘Top Posts’ widget?’ is closed to new replies.