I've an issue on custom post type, I've create a custom post type called "Agenda" and the rewrite url for http://example.com/agenda it works correctly, it points to the archive-agenda.php template but for http://example.com/agenda/page/2 it shows 404 error, what do you suggest me? The code that I've used to add the custom post type is:

function create_event_type() {
    $event_args = array(
        'label' => __('Agenda'),
        'singular_label' => __('Evento'),
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => true,
        'has_archive' => true,
        'publicly_queryable' => true,
        'show_in_nav_menus' => true,
        'query_var' => true,
        'supports' => array(
            'revisions', // (will store revisions)
            //'page-attributes', // (menu order, hierarchical must be true to show Parent option)
    register_post_type('agenda', $event_args);
add_action('init', 'create_event_type');

Thanks in advance!

  • I see you have a closing tag, just encase, this code needs to be in functions.php or in a plugin, placing it in a template means when the code runs it's too late
    – Tom J Nowell
    Aug 21, 2014 at 23:19
  • What @TomJNowell is saying is that your add_action function is running too late. Place it at the earliest possible place infunctions.php or a plugin file somewhere. Sep 25, 2016 at 6:55
  • Lol, I still can't operate this site. 3 year old question shows up on the top of my feed... I have no clue why. Whatever, please enjoy my banter, it is meant to be helpful. Sep 25, 2016 at 7:15

3 Answers 3


You need to reset your permalinks... "powercycle them" :) click "Numeric" -> Save then back to "Post Name" and save (or vice versa)

  • 4
    just visiting the permalinks settings page flushes rewrite rules, no need to change anything.
    – Milo
    Mar 1, 2013 at 23:43
  • Good to know @milo! Mar 7, 2013 at 18:32
  • @BenRacicot I don't even know what click "Numeric" -> Save means. What is that? Sep 25, 2016 at 7:03
  • @milo does entering that page flush, or do you have to save? Sep 25, 2016 at 7:07
  • People say entering the page flushes them but has never worked for me. I've always had to re-save URL format to "Numeric" then switch them back to the desired format. Sep 25, 2016 at 21:27

You need to setup pagination when you query your custom post something like this

$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

  • This is the right track. Your template will have to have this code, especially if it is custom. Research in this area will get you everywhere. Sep 25, 2016 at 7:06

I had the same problem and I found the answer today. I've added a rewrite rule for a workaround.

check my answer for this question: wrong template for page of archive

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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