I have inherited an existing site and have recently been asked to make some changes.

They have 'renamed' the default post as 'latest-news' using this 'my_new_default_post_type':


add_action( 'init', 'my_new_default_post_type', 1 );

    function my_new_default_post_type() {

      register_post_type( 'post', array(
          'labels' => array(
              'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
          'public'  => true,
          '_builtin' => false,
          '_edit_link' => 'post.php?post=%d',
          'capability_type' => 'post',
          'map_meta_cap' => true,
          'hierarchical' => false,
          'rewrite' => array('slug' => 'latest-news','with_front' => false),
          'query_var' => true,
          'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
      ) );



These can be seen being listed on a standard page here:


with the second page of pagination here:


Clicking into a post loads it here:


I have added some new custom post types, one example of which is 'corparate-deals'. The code to add this custom post type is:


    add_action('init', 'corporate_deals_register');

    function corporate_deals_register() {

     $labels = array(
        'name' => _x('Corporate Deals', 'post type general name'),
        'singular_name' => _x('Corporate Deals', 'post type singular     name'),
        'add_new_item' => __('Add New Briefing'),
        'edit_item' => __('Edit briefing'),
        'new_item' => __('New briefing'),
        'view_item' => __('View briefing'),
        'search_items' => __('Search Corporate Deals'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''

    $args = array(
      'labels' => $labels,
      'public' => true,
      'has_archive' => false,
      'show_ui' => true,
      'capability_type' => 'post',
      'taxonomies'  => array( 'category' ),
      'hierarchical' => false,
      'publicly_queriable' => false,
      'show_ui' => true,
      'show_in_nav_menus'  => false,
      'exclude_from_search' => false,
      'menu_icon' => 'dashicons-welcome-add-page',  // Icon Path
      'menu_position' => 5,
      'show_in_menu'  =>    'blogs_menu',
      'query_var' => true,
      'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions' ),

    register_post_type( 'corporate-deals' , $args );


You can see these listed here:


and clicking into one here:


However... when you try to view the second page of pagination, here:


it redirects to:


I have searched high and low for any redirects or rewrite rules but cannot find any.

One thing I did notice is that if I add:

'rewrite' => array('slug' => 'latest-news','with_front' => false),

to my custom post declaration (i.e. rewriting the 'corporate-deals' to 'latest-news') then the redirection doesn't occur.

Any help greatly appreciated. Thanks in advance.


The code that builds the post listing is:

<?php // Corporate Deals

function paginatedcorporatedeals_func( $atts ) {

  extract( shortcode_atts( array(
    'pageid' => '{$pageid}',
    'title' => '{$title}',
    'showcontent' => '{$showcontent}',
    'newsurl' => '{$newsurl}',
    'postmeta' => '{$postmeta}'
  ), $atts ) );


  global $post;

  $ws = 1;

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

  $args = array(
    'posts_per_page' => 16,
    'paged' => $paged,

  $slug = the_slug();


  // global $wp_query;

  // $postcount = $wp_query->found_posts;


  if(have_posts()) {

    $divider = 'yes';
    $featuredimg = 'date';
    $truncate = 250;

    while (have_posts()) : the_post();

      global $post;

      $thetitle = get_the_title($post->ID);

      require get_template_directory() . '/assets/inc/plugins/vc-intergration/modules/shortcode-templates/media-list.php';

      $output .="<hr>";



    $output .=  "<div class='vc_row clearfix'><div class='white-bar'>".page_pagination()."</div></div>";


  return $output;


add_shortcode( 'paginatedcorporatedeals', 'paginatedcorporatedeals_func' );

  • Is there a reason why you have created https://gateleyplc.com/corporate-deals as a page with a shortcode, rather than use the custom post type archive page that WordPress generates? – Milo Aug 14 '18 at 15:43
  • I would rather have used an archive page as you suggest. I was trying to follow the existing layout/standards that the site has been built with. The page remains editable 'around' the list content and styling wise is in-keeping with the 'latest-news' list page. Restyling the auto generated archive pages to match the 'latest-news' page and list plugin will be my last resort. Thanks for the feedback. – Oliver Ashford Aug 15 '18 at 9:55
  • When you visit /corporate-deals/page/2/, WordPress is querying for the 2nd page of a singular corporate-deals post with the slug page. If you used the built-in archive instead of a page, this issue would disappear. You'll need to add your own rewrite rules to override the ones generated for your post type. – Milo Aug 15 '18 at 15:38

just remove template redirect using remove template_redirect filter

use below code to stop the canonical redirect.


  • I added that at the bottom of functions.php for the theme and unfortunately it is still redirecting. – Oliver Ashford Aug 14 '18 at 13:31
  • You should test for a specific condition in redirect_canonical and return false in that one case rather than completely remove the filter, which will break all kinds of other cases where you will want that redirect. – Milo Aug 15 '18 at 12:59

According to me, the reason for these paging problems is 'publicly_queriable' => false, in your $args for register_post_type(). Change it to TRUE (default value) or comment out and pagination will work.

publicly_queriable argument should not be false unless the post type you are registering is not public.

  • I tried this and unfortunately it didn't work (although I think your suggestion is the right thing to do generally.) Thanks for the answer – Oliver Ashford Aug 15 '18 at 9:53

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.