here is a code example to hide post. However you need to use a custom meta for this to work. So, add a new meta with the post you want to hide. Use meta key name as ‘hidethis’ and use value ‘1’. Don’t use the quote marks, just the texts.
Next this is to add a code to your themes functions.php. You can edit it directly from your wp-admin -> themes -> editor page. Just find the file name (on right side) functions.php and add the following code, then hit update button.
add_action( 'pre_get_posts', 'pre_get_posts_127256', 9999 );
function pre_get_posts_127256($q){
if( is_admin() )
return;
if( is_singular() )
return;
$mq = $q->get('meta_query');
$nm = array('key' => 'hidethis', 'compare' => 'NOT EXISTS');
$mq[] = $nm;
$q->set('meta_query', $mq);
}
This should be hiding the post u added meta key ‘hidethis’ with a value.
Related Posts:
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Disallow a user to post in certain categories
- Article source link for posts
- Publish Post After Click On A Link
- Get the last post ID
- Enable comments for post with comments meta box removed
- Custom Post Type causes Page Not Found
- Unique post-id for WordPress Multisite Network
- Is there an action that is called when a post is restored from the trash?
- Replace existing pages with new pages, keep menu links
- CKEditor: Uncaught TypeError: switchEditors.switchto is not a functiononclick
- New post notification plugin [closed]
- Adding Plugin-specific Fields with wp_insert_post()?
- Output HTML only on individual post view
- Execute a plugin only on post pages
- Portfolio + Blog: multisite or plugin?
- Cron job not firing
- How to enable qTranslate languages tabs in custom plugin page
- How do I “get the next 10 posts after post_id == x”?
- Calendar Solution: Handling upcoming Dates with Posts?
- get_post_type on post.php
- finding whether request is for post, and post id
- Can’t delete Draft Post [closed]
- Outbound link autometic converted into linkdirect , and not opening
- Display by Category in Admin
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Contributive page where people logged in can write
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Display wordpress post’s in popup?
- Redirect to another page using contact form 7? [closed]
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Is it possible to send blog posts via email to subscribers?
- Is there any plugin which can paste a common content to my every post?
- Recent posts per category loop?
- Problem of encoding characters (apostrophes) in my posts publications
- How to backup single post in wordpress [closed]
- Is there a way to make the main page only display a brief description of the full article?
- How to change the post form from plugin?
- Allowing users to Sign-up > Login > Post articles that need approval
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Is there a plugin or a way in the wordpress that would let us have different versions of a post or page accessibe to users?
- download button for audio file in post [closed]
- check uncategorized category by default
- Print posts category or tag as a formatted journal
- Post deleted in trash [closed]
- How to relate 3 wordpress components with each other (Create database relationships)
- What hook can I use to modify custom post data before it is displayed on the page?
- get current page number with wp_link_pages()
- problem with register_activation_hook in plugin
- Delete data from custom table when deleting a post
- Plugin is creating posts twice
- How to write a new file when new post has been published in WordPress
- How to Get Recent 5 post in My Title bar?
- How to get Recent Post From Each Category with Thumbnail?
- Plugin for visitors to edit content without logging in? [closed]
- WP Insert Post If user refreshes override new post
- Summary and Comments on Main landing Page
- Method/Plugin/Hack to Start a Post with an Writing Outline?
- What snippet do I need to type to show my ACF field show up on my theme?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Why the internal link get converted into a comment?
- Is it possible to pin a post in second position from top
- Oops! That page can’t be found
- page duplication on wordpress that wont stop
- Copy/paste local images not working in WordPress
- How to change my 3000 Published post status to Draft using PHPMyAdmin
- WordPress is redirecting me to homepage
- Adding custom post category to categories widget
- How can I see $post object in frontend from functions.php?
- Allow members to create groups on my site
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How to wrap image tag into div for post only?
- My own metabox checkbox plugin only saves the last value I’ve checked
- How to prevent authors from editing their post count?
- How to force regenerate thumbnails in WordPress posts?
- Publish Post but don’t call publish hook in foreground post creation
- Serialize $_POST global in wordpress
- How to use shortcode of any plugin to show it visually where i want?
- WordPress not updating post or disable plugin instead a white page appear
- get post excerpt by query
- Ger posts from similar tags and categories
- Internationalization of Blog Posts
- Issues with Post 2 Post Plugin
- How to add character to content of post?
- single.php fires more than once after clicking on any post to view with different post id each time
- Twitter List Tweets and Delicious Links as Posts
- Custom feed parameters / Template overriding
- How to make only selected posts appear on a selected wordpress page
- How to block external download link access if visitor not referred from WP?
- Plugin to display text before a post
- Notifications Bar on home page only
- Distribute post content through several divs [closed]
- Does anyone have the Custom Post Permalinks plugin from John P. Bloch? [closed]
- Shortcode returning specific content of a post
- How to get an error message if a form is empty (plugin: Post for site) [closed]
- How to customized post slider layout in elementor wordpress [closed]
- How to export post tags from wordpress
- Show WooCommerce products based on query parameters on redirect
- Getting 400 Error in wordpress website