Your best way would be to redirect to the theme’s 404 page in the event that the page being loaded matches the slug that you are referring to. Try this:
function check_undesirable_page(){
global $post;
if(is_page() && ($post->post_name=="YOUR-SLUG-HERE")){
global $wp_query;
$wp_query->set_404();
status_header(404);
}
}
add_action( 'wp', 'check_undesirable_page' );
EDIT: Also a good idea to incorporate the is_page()
condition (added above) to avoid undesirable consequences of the page sharing its slug with other items (in case it’s a common word)
Related Posts:
- What file is the standard frontpage that lists all the posts?
- If I moved the location of my generic “posts” page, do I need to change the slugs for all of the individual posts?
- Remove slug from custom post type post URLs
- Keep featured content post in homepage with original order
- Where is the old post permalink slug stored?
- Access post from post id in URL
- How to add category to: ‘wp-admin/post-new.php’?
- How to Check if a Page Exists by URL?
- Use category base slug in posts’ permalink
- Custom Post Types, slug, archive and SEO plugins
- Strategy for handling hierarchical pages with empty parent content
- How to automatically generate a unique random slug
- Post slugs and images cannot have same name?
- Natural URL Design and static front page
- Change the Slug of Post Type post to baseurl/post/%postname%
- Open WordPress ‘Add New Post’ admin page with parameters set via $_GET
- Template file for static posts page does not get loaded?
- How do you get all the urls of images attached to a post?
- How to control which category will be picked for the slug of a post?
- Change slug with custom field
- How can I display 7 posts on the home page, but 9 posts on the subsequent pages?
- Determining Slug Before and After Edit
- how to display full post with pagination on home page
- How to allow slashes in single posts when i click in the edit permalink button
- How can I specify a category post on my home page
- How to update all post at once?
- Hide parts of the post content on the home page
- Show post titles only on the homepage
- Possible to create a permalink to sort with meta_key?
- how to grab first link in post… and of course call it
- Displaying Page Title on index.php
- Linking to page with all posts
- How can I extract the URL of a link from a post?
- generate unique slug while inserting post
- Can I hide a specific post from latest posts page?
- How do I get the slug of a custom taxonomy category of a post?
- How to link up “read more” on excerpts hack from WP Recipies
- Create a separate JS application for an individual post?
- How to get posts by multiple post slugs? [duplicate]
- Define a name to the posts slug
- Can I set and show “important” post in my blog?
- if I create ‘front-page.php’, then how do I link to post index?
- Remove slashes (both before and after) in relative post url
- How can I remove posts of a certain category from homepage after a specified time period?
- Random post category URL
- Bulk update post slugs through database
- How to make the post summary taller?
- Static page does not show my posts
- Limit posts per author role (excluding admin) in home page
- Properly display posts on homepage
- Paginated Posts – Social Media Buttons Share First Page URL
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- WordPress not opening posts with only numbers if permalink is post_name
- How to show last post of each website of a MU wordpress in HomePage
- Assign category to new post via URL
- Move first half of posts to one parent page, second half to the other page
- filter RSS feed in URL
- How to have posts have a parent in permalink like site.com/blog/postname
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Editing the default page to show all posts, rather than most recent ones
- Include sticky posts on the static page front page
- Automatically add date to the auto generation of post slug
- How to handle broken links created by permalink/slug changes?
- Visting slug for ‘post’ post type shows 404 not archive?
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- how do i add posts-page slug before posts slug in permalinks
- Permalink doesn’t get displayed in Twitter button (Local WordPress problem?)
- Retrieve post ID from “querying” URL
- Start post pagination at 0 instead of 1
- Redirect to another page using contact form 7? [closed]
- How to get a post’s content? [closed]
- Hide posts belongs to few categories in homepage
- How do I Redirect a WordPress Page?
- posts not showing on index.php
- Disable WordPress Archive Conflict Check
- Linking to pages/posts within the site
- WP move posts to different path
- How to Use index.php file for “Blog” Page And this is Not a Home Page
- Loop doesn’t exclude the specified category in home page
- Two Custom Post Types with Identical Articles Competing for the same Slug
- WordPress custom post type with folder structure in slug
- Single Post in Tab/Slider
- Getting Duplicate Posts on Home Page with Widget Added Between Posts
- Make insterted image point to post url instead of attachment page
- my post slug gets really long and I can’t change it
- Replace image name on upload to the new post name on front-end form
- Edit the post title from the frontend
- Show custom post with custom categories with specific slug
- Post is blank when I click on the link
- How to call posts under a specific category on static front page?
- Add hero image to home page (blog format) via the dashboard
- Custom home page with full post for first one only
- How to get the latest URL of my blog?
- Auto update post title and slug when post status is changed
- WordPress loop not working on static front page
- Show posts on front page only
- Inserting an example of the last 3 post on to the homepage
- I don’t want the complete article to show on homepage
- post type slug vs page slug
- Post is in descendant category not working in home.php