Here is my case, I’m making some experiments with post types, basically I created a post type called Slider where the featured image is will display in the slide.
Now, when user type something like domain.com/slider/slide1, or try to reach the slider post, I want to display a not found page instead of the single page, or the index in case I dont have the post single page.
Is it possible to achieve?
Solved!
Thanks to Saif Bechan, I could solve my problem,
Basically I used this function
add_action('template_redirect', 'my_template_redirect');
function my_template_redirect() {
global $wp_query, $post;
if(is_singular('Slider'))
{
$wp_query->set_404();
}
}
Where Slider is the Post Type name,
I have a script that wil; display a good 404 page for certain pages. Now I do not yet know what custom post types are, as I am just starting, but I think you can edit the script to fit your needs.
Hope you can do something with this this code. I use this in my
functions.php
to block access to the different parts of the website. They are also blocked for feeds.You could just copy your index.php file and name it 404.php. Then if a page or attachment page wasn’t found it would use the 404.php page which would just be a copy of the index.php file.
If I understand you correctly create a page template named 404, then use this plugin: http://wordpress.org/extend/plugins/custom-post-template/ which will allow you to choose it as the template for that page.