Admin Filter – Add Post Type Description on Post Type Page

The filter views_{$this->screen->id} is fired just after the title of post edit screen has been print to screen, so it’s a safe place to just echo what you want. So you can simply do: function post_type_desc( $views ){ $screen = get_current_screen(); $post_type = get_post_type_object($screen->post_type); if ($post_type->description) { printf(‘<h4>%s</h4>’, esc_html($post_type->description)); // echo } return $views; // … Read more

Custom post status not working

The post status values seems to be hardcoded in the core. Here’s the status box code for the edit screen: <span id=”post-status-display”> <?php switch ( $post->post_status ) { case ‘private’: _e(‘Privately Published’); break; case ‘publish’: _e(‘Published’); break; case ‘future’: _e(‘Scheduled’); break; case ‘pending’: _e(‘Pending Review’); break; case ‘draft’: case ‘auto-draft’: _e(‘Draft’); break; } ?> </span> … Read more

Save Press This Posts in a Custom Post Type

Here’s a simple plugin to modify the Press-This post type: <?php /** * Plugin Name: Press-This Custom Post Type * Plugin URI: http://wordpress.stackexchange.com/a/192065/26350 */ add_filter( ‘wp_insert_post_data’, function( $data ) { $old_cpt=”post”; $new_cpt=”page”; // <– Edit this cpt to your needs! $obj = get_post_type_object( $new_cpt ); // Change the post type if( doing_action( ‘wp_ajax_press-this-save-post’ ) // … Read more

Display Authors Comments on Profile Page

What you need to use here is the WP_Comment_Query() function. So on the author.php page, you can easily get the author info and ID as followed: // get author info $curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author)); // set ID $user_id = $curauth->ID; Then we add the user ID in the query arguments array: … Read more

Custom Post Types not showing on Custom Taxonomy archive page

By default, all public post types are included in the main main query on taxonomy pages. If you look at register_post_type()’spublic parameter when set to true ‘true’ Implies exclude_from_search: false, publicly_queryable: true, show_in_nav_menus: true, and show_ui:true. When you register your post type, you set exclude_from_search to true. This does not only remove the custom post … Read more

Display a list of child posts on parent posts of a custom post type

The best way is using WP_Query. I think your error or plugin error could be that the ‘post_type’ of childs is not define. WP Query : https://codex.wordpress.org/Class_Reference/WP_Query global $post; $args = array( ‘post_parent’ => $post->ID, ‘posts_per_page’ => -1, ‘post_type’ => ‘products’, //you can use also ‘any’ ); $the_query = new WP_Query( $args ); // The … Read more

Now can I group custom post types together?

If you are wondering how to group multiple post types under one menu, you can easily do this with the show_in_menu argument when setting up your menu. See below: $args = array( ‘public’ => true, ‘show_ui’ => true, ‘query_var’ => true, ‘rewrite’ => true, ‘capability_type’ => ‘post’, ‘hierarchical’ => false, ‘show_in_menu’ => ‘your-custom-menu-slug.php’, ‘menu_position’ => … Read more

Rewrite custom post type rss feed links

Put this in a plugin or functions.php: function feed_rewrite( $wp_rewrite ) { $feed_rules = array( ‘feed/portfolio’ => ‘index.php?post_type=post&feed=rss2’ ); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if this is changed in any way add_filter( ‘generate_rewrite_rules’, ‘feed_rewrite’ ); When you’ve done that, go to the permalinks page and resave to flush … Read more