• Hi,

    I have a huge problem with my custom post type and I have NO IDEA why it won’t work, since it used to work perfectly before and I didn’t really change anything on the code. It looks like this:

    <h3><?php the_title(); ?></h3>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    I have 3 of my 7 articles from my custom post type displayed on the front site but when I click on their links using the_permalink(), it always brings me to a 404 page.

    How do I fix this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Basic first step when dealing with Permalink 404 issues is to go to the permalink settings page and set them to default, then set them back to the rewrite setting you are currently trying to use.

    This especially comes up with custom post types because they have an argument to rewrite the taxonomy slug.

    Give that a try to get it out of the way and post back if the problem is still there.

    Thread Starter Raider000

    (@raider000)

    Well, when I set the permalink settings to default, the URLs seem to work but it absolutely destroys the layout of my whole website. And when I change the setting back to the way it was, they won’t work and still lead me to the 404 page.

    What’s your custom permalink structure ? Is the custom permalink structure needed to make your theme work? What theme are you using?

    Thread Starter Raider000

    (@raider000)

    I use my own theme and use post name as permalink (https://mysite.com/sample-post). The theme wasn’t meant to work with this permalink structure only but I would like to keep the same settings though.

    when I set the permalink settings to default, the URLs seem to work but it absolutely destroys the layout of my whole website

    Why? No theme should be dependant upon a given custom structure. A well-coded theme can handle any permalink structure.

    Thread Starter Raider000

    (@raider000)

    That’s because none of the URLs (css, JS etc.) gets loaded.

    From the Codex:
    Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hence permalink.
    Permalinks are not responsible for the paths pointing to CSS or JS files so i don’t get it when you say:

    none of the URLs (css, JS etc.) gets loaded.

    Can you post your site URL?

    Thread Starter Raider000

    (@raider000)

    Sure, it’s https://goo.gl/5lQR44 but I have now reset the permalink structure back to post name.

    Please, check this thread

    Thread Starter Raider000

    (@raider000)

    Well thanks but I don’t think that this is the right solution to my issue. I even deactivated WooCommerce and it was still all the same. Even when I want to view the created page from the backend, it comes up with 404. It’s just weird that they get loaded on the front page but not when you want to browse them single using the permalink.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘404 error page using the_permalink()’ is closed to new replies.