I am developing a theme for WordPress by following some tutorials. The main page works well, loading post of a custom post type, and the page to see the contents of the cpt also following the Wordpress nomenclature: single-{name-cpt}.php.

The problem is when I create a normal page. When entering the URL of the page, the error page appears 404.php.

I have refreshed the link structure and verified that the .htaccess is correct.

What could be happening so that it does not load page.php?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Custom links structure: /blog/%postname%/


Function code to create cpt:

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'videos_porno',
      'labels' => array(
        'name' => __( 'Videos porno' ),
        'singular_name' => __( 'Video porno' )
      'public' => true,
      'has_archive' => false, //true
      'hierarchical' => false,
      'rewrite' => array('slug' => '', 'with_front' => false),
      'register_meta_box_cb' => 'add_metaboxes_video_porno',
      'supports' => array( 'title', 'editor', 'thumbnail' )

  $args= array(
    'label' => 'Servidores',
    'hierarchical' => false,
    'rewrite' => false,
  register_taxonomy( 'servidores', 'videos_porno', $args );

function my_rewrite_flush() {
add_action( 'after_switch_theme', 'my_rewrite_flush' );

Before implementing the code that the cpt adds, everything works correctly.

With the link structure /blog/%postname%, Is it possible that cpt posts and pages share the directory "/" for urls?

1 Answer 1


To determine if there is something wrong with your server settings or with your theme, you can write a very simple theme that will display different results for the custom post type.

I just tried that with the following theme:


 * Theme Name: WPSE


function wpse_init() {
  register_post_type( 'wpse', array(
    'labels' => array(
      'name' => 'wpse',
    'public' => true,
  ) );
add_action( 'init', 'wpse_init' );


echo 'index';


echo 'single-wpse';

I then created a new wpse custom post type with a slug of 'test'. When I navigated in a browser to /wpse/test I saw a page that said 'single-wpse' as expected.

Note: After switching themes, I needed to refresh the rewrite rules or I saw a 404 on the custom post types.

If you do this and still see a 404, then it's a server configuration issue. If you see 'single-wpse' then it's something wrong with your theme. I would guess that you are probably using the custom post type label instead of the custom post type slug.

  • Testing the test topic you have written, the test slug works correctly under the url / blog / wpse / test / even without restarting the permanent links. I created a normal page and it shows the text "index.php"
    – Mike
    Apr 4, 2018 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.