I have created a custom post type in WordPress with CPT UI named eggs.
In the file named eggs.php I put this code:
<?php
$args = array('post_type' => 'eggs');
$query = new WP_Query($args);
?>
<?php if ($query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<a href="<?php the_permalink(); ?>" Go to Eggs Single Page</a>
<?php endwhile; endif; wp_reset_postdata(); ?>
Now I have created a file named single-eggs.php and when I click on the permalink it redirects me on a page where it says “Sorry, no posts matchef your criteria.” . It doesn’t go to the page single-eggs.php as I want.
EDIT: Currently I am using Custom Post Type UI plugin by WebDevStudios.
When I’m using the Types plugin from OnTheGoSystems it finds the single-template.php. Is it something wrong with the plugin maybe?
Instead of using a plugin to register your Custom Post Types, you could simply use
register_post_type
function to register your own CPT:Put the above snippet in your
functions.php
file.After that you may create your
single-eggs.php
and everything will be OK.Keep in mind that you may need to refresh the rewrite rules. To do so, you should go to
and simply hit the Save settings button at the bottom.