I’ve inherited an present web site and have not too long ago been requested to make some adjustments.
They’ve ‘renamed’ the default publish as ‘latest-news’ utilizing this ‘my_new_default_post_type’:
<?php
add_action( 'init', 'my_new_default_post_type', 1 );
perform my_new_default_post_type() {
register_post_type( 'publish', array(
'labels' => array(
'name_admin_bar' => _x( 'Publish', 'add new on admin bar' ),
),
'public' => true,
'_builtin' => false,
'_edit_link' => 'publish.php?publish=%d',
'capability_type' => 'publish',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'latest-news','with_front' => false),
'query_var' => true,
'helps' => array( 'title', 'editor', 'creator', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'feedback', 'revisions', 'post-formats' ),
) );
}
?>
These could be seen being listed on a normal web page right here:
https://gateleyplc.com/news-events/latest-news/
with the second web page of pagination right here:
https://gateleyplc.com/news-events/latest-news/web page/2/
Clicking right into a publish masses it right here:
I’ve added some new {custom} publish sorts, one instance of which is ‘corparate-deals’. The code so as to add this tradition publish sort is:
<?php
add_action('init', 'corporate_deals_register');
perform corporate_deals_register() {
$labels = array(
'title' => _x('Company Offers', 'publish sort normal title'),
'singular_name' => _x('Company Offers', 'publish sort singular title'),
'add_new_item' => __('Add New Briefing'),
'edit_item' => __('Edit briefing'),
'new_item' => __('New briefing'),
'view_item' => __('View briefing'),
'search_items' => __('Search Company Offers'),
'not_found' => __('Nothing discovered'),
'not_found_in_trash' => __('Nothing present in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'show_ui' => true,
'capability_type' => 'publish',
'taxonomies' => array( 'class' ),
'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,
'helps' => array( 'title', 'editor', 'creator', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions' ),
);
register_post_type( 'corporate-deals' , $args );
}
?>
You possibly can see these listed right here:
https://gateleyplc.com/corporate-deals
and clicking into one right here:
Nevertheless… whenever you attempt to view the second web page of pagination, right here:
https://gateleyplc.com/corporate-deals/web page/2/
it redirects to:
I’ve searched excessive and low for any redirects or rewrite guidelines however can not discover any.
One factor I did discover is that if I add:
'rewrite' => array('slug' => 'latest-news','with_front' => false),
to my {custom} publish declaration (i.e. rewriting the ‘corporate-deals’ to ‘latest-news’) then the redirection does not happen.
Any assist enormously appreciated. Thanks upfront.
Moreover
The code that builds the publish itemizing is:
<?php // Company Offers
perform paginatedcorporatedeals_func( $atts ) {
extract( shortcode_atts( array(
'pageid' => '{$pageid}',
'title' => '{$title}',
'showcontent' => '{$showcontent}',
'newsurl' => '{$newsurl}',
'postmeta' => '{$postmeta}'
), $atts ) );
$output;
world $publish;
$ws = 1;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type'=>'corporate-deals',
//'order'=>'ASC',
'posts_per_page' => 16,
'paged' => $paged,
);
$slug = the_slug();
query_posts($args);
// world $wp_query;
// $postcount = $wp_query->found_posts;
$rely=0;
if(have_posts()) {
$divider = 'sure';
$featuredimg = 'date';
$truncate = 250;
whereas (have_posts()) : the_post();
world $publish;
$thetitle = get_the_title($post->ID);
require get_template_directory() . '/belongings/inc/plugins/vc-intergration/modules/shortcode-templates/media-list.php';
$output .="<hr>";
$rely++;
endwhile;
$output .= "<div class='vc_row clearfix'><div class='white-bar'>".page_pagination()."</div></div>";
wp_reset_query();
}
return $output;
}
add_shortcode( 'paginatedcorporatedeals', 'paginatedcorporatedeals_func' );
?>