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:
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- publish_post hook isn’t working for scheduled posts
- How to get posts by content?
- Plugin for changing a post’s category based on it’s post date?
- WP get_permalink Return Wrong URL
- Edit/revise option for authors to suggest improvement to posts [closed]
- post expire after x days
- Action on post publish
- [Plugin: Posts 2 Posts] How does it work?
- Set attached to state
- Use plugin or custom post type for game score functionality
- Tag link suggestion plugin
- How to add new tabs in post.php
- Bulk Image Uploader to create new post from each image [closed]
- Display comments of users on single page
- Using the “Latest posts” feature on a different site
- Post query – show posts from specified day and month and whole years
- Is there a way to order posts and custom post types as one group?
- How can i list random post from multiple category?
- Support for simultaneous editing
- Accessing post’s meta data based on user’s click of a post
- View Private Published Page with URL Code (no login required)
- Solutions to repost categories into multisite blogs?
- submit posts by unregistered users in wordpress
- Display post lists in 2nd paragraph
- Matching Chapters to a Custom posts [closed]
- WordPress display breadcrumbs using Yoast plugin [closed]
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- Two problems on my WordPress installation [closed]
- Excerpts on category page
- External RSS feed to WordPress Portfolio
- Redirect to another page using contact form 7? [closed]
- Is it possible to send blog posts via email to subscribers?
- Custom setup of wordpress comments that are displayed
- Is there any plugin which can paste a common content to my every post?
- Import Instagram post to WordPress blog post
- How to get all posts belongs to a user between a certain date
- Making my plugin create a page?
- How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
- check uncategorized category by default
- Article content navigator in wordpress like mbaskool website
- Getting a list of the published posts
- If post exists in the database – each time goes on `else`
- 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()
- How can i summerize posts or news automatically in word press site?
- Delete data from custom table when deleting a post
- Plugin is creating posts twice
- Edit part of a post
- How to write a new file when new post has been published in WordPress
- WordPress Stats Plugin: Display Post Views [closed]
- How to Get Recent 5 post in My Title bar?
- 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?
- Is there a way to make [Table Of Content] plugin while not using revision data?
- Oops! That page can’t be found
- Help to Create a Simple Plugin to make a post
- New posts are not showing up on my front page
- WordPress is redirecting me to homepage
- Adding custom post category to categories widget
- Randomize post (and page) IDs on generation
- Moving all wordpress posts from 50 websites to another website
- Powerpress upload a podcast without creating a post for it
- add tags to wordpress post using REST API
- How to make a page both “private” and “password protected”
- Failed to load resource: the server responded with a status of 500 () post.php
- How to upload PDF from Front-End and post automatically?
- How to wrap image tag into div for post only?
- Get value from an input field and pass into update_meta_data as $meta_value
- My own metabox checkbox plugin only saves the last value I’ve checked
- Get content and send to 3rd party
- How to prevent authors from editing their post count?
- Is it possible to get a shortcode generated by a plugin, then, using a function, create a new post using that shortcode?
- Different email notifications (about pending posts) to different users
- How to display single arbitrary facebook post with a shortcode?
- Custom post type request switches to media request
- Ger posts from similar tags and categories
- How to Batch Upload .docx Files as Posts
- WordPress ultra slow if I click on posts?
- 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
- Most visited posts
- How to make only selected posts appear on a selected wordpress page
- wp_update_post does not change post status from draft to publish, returns 1
- Static page with formatted post list
- How to block external download link access if visitor not referred from WP?
- Automatically put a menu on every post
- Preset categories in wordpress by GET-paremters [duplicate]
- 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]
- hide particular category post from front page only [closed]
- Is there a plugin or another way that can help me find out the underlying files of a page/post? [closed]
- How to update a lot of posts on my WP site with additional content?
- Show the author only own types of publications. (JetEngine, Elementor)
- Randomly display activity posts on home page with buddypress
- How to check if the post exists in any of the categories?