Change name of custom post type archive

The register_post_type has_archive option also accepts a string. That string will be used for the archives. See the changes in the code below: function create_reviews_post_type() { register_post_type(‘acme_reviews’, array( ‘labels’ => array( ‘name’ => __(‘Reviews’), ‘singular_name’ => __(‘Review’) ), ‘menu_position’ => 5, ‘public’ => true, ‘has_archive’ => ‘reviews’, ); } add_action(‘init’, ‘create_reviews_post_type’);

taxonomy template for custom post type the same as the archive

Thanks for Milo’s pointer function department_template( $template=”” ) { if (is_tax(‘department’) ) { $template = locate_template( ‘archive-team.php’ ); } return $template; } add_filter( ‘taxonomy_template’, ‘department_template’ ); Worth noting this doesn’t disturb the hierarchy if another taxonomy is involved, ie taxonomy-othertax.php is called correctly for taxonomy ‘othertax’.

Loop on front-page.php

This is how you would do it. You’re loop is based on being in an archive or index page. (or home) $args = array( ‘posts_per_page’ => 3, ‘post_type’ => ‘post’, //choose post type here ‘order’ => ‘DESC’, ); // query $the_query = new WP_Query( $args ); if( $the_query->have_posts() ): while( $the_query->have_posts() ) : $the_query->the_post(); get_template_part(‘loop’); … Read more

Redeclare slug & name of custom post type?

WordPress provides the register_post_type_args filter to let users do this: function wpd_modify_post_type( $args, $post_type ){ if( ‘reviews’ == $post_type ){ $args[‘labels’][‘name’] = ‘New name’; $args[‘labels’][‘singular_name’] = ‘New singular name’; $args[‘rewrite’][‘slug’] = ‘new-slug’; } return $args; } add_filter( ‘register_post_type_args’, ‘wpd_modify_post_type’, 10, 2 ); Keep in mind that if the slug changes, the user will need to … Read more

Output custom post shortcode. Help spot the error.

You’re resetting the value of $output each time you go through the loop: foreach ($row as $post) { // etc. $output=”<div class=”col-md-6 event-item”>”; // Here $output // etc. } That $output assignment is resetting the value of $output to ‘<div class=”col-md-6 event-item”>’, throwing out everything that had been appended to it. You’re also returning $output … Read more