How to show only the most recent post on my custom post type archive?

You could just alter the main query for your custom post type archive with pre_get_posts(). Code: function wpse124228_alter_ppp_order_for_mycpt( $query ) { if ( ! $query->is_main_query() || is_admin() ) return; if ( is_post_type_archive( ‘mycpt’ ) ) { //Only display 1 post on mycpt archive $query->set( ‘posts_per_page’, 1 ); //Most recent/current $query->set( ‘orderby’, ‘date’ ); $query->set( ‘order’, … Read more

Add a custom text to admin footer in a Custom Post Type page

This should do. Put the following in your functions.php if (in_array($GLOBALS[‘pagenow’], array(‘edit.php’, ‘post.php’, ‘post-new.php’))) add_filter(‘admin_footer_text’, ‘my_custom_footer_admin_text’); function my_custom_footer_admin_text($text) { $post_type = filter_input(INPUT_GET, ‘post_type’); if (! $post_type) $post_type = get_post_type(filter_input(INPUT_GET, ‘post’)); if (‘my_post_type’ == $post_type) return ‘my custom message’; return $text; }

Archive not sorting correctly

Have a look at the orderby parameters for WP_Query to see all of the valid values that can be. If wpcf-start-time is a meta key, then orderby should be meta_value, which will also require you set a meta_key argument to tell WP what meta key you want to order on- } elseif ($q->is_post_type_archive(‘cif-events’)) { $q->set(‘orderby’, … Read more

How to add terms (without deleting others)

The fourth parameter to wp_set_object_terms() is an “append” argument. $append (bool) (required) If true, tags will be appended to the object. If false, tags will replace existing tags Default: False http://codex.wordpress.org/Function_Reference/wp_set_object_terms Your code should work if you pass true as that fourth argument. wp_set_object_terms( $post->ID, explode( ‘,’, $_POST[‘postTags’] ), ‘product_tag’, true );

Custom post type capability type ‘page’ not working

I’ve taken this from another site I have made which uses the hierarchical structure and it works. (I have amended to fit your post type) function register_publications_cpt() { $labels = array( ‘name’ => _x(‘Publications’, ‘post type general name’), ‘singular_name’ => _x(‘Publication’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ”), ‘add_new_item’ => __(‘Add New Publication’), … Read more

How do I add a Custom Post Type that looks and behaves exactly the same as Posts?

Creating the Post Type register_post_type is your friend here. This is what plugins etc use to register the post type. For example here is a basic Books post type: function codex_custom_init() { $args = array( ‘public’ => true, ‘label’ => ‘Books’ ); register_post_type( ‘book’, $args ); } add_action( ‘init’, ‘codex_custom_init’ ); If you don’t want … Read more