why doesn’t the_content() work in this {single-custom_post_type.php} page?

Some post-related data is not available to get_posts by default, such as post content through the_content(), or the numeric ID. This is resolved by calling an internal function setup_postdata(), with the $post array as its argument: <?php $args = array( ‘posts_per_page’ => 3 ); $lastposts = get_posts( $args ); foreach ( $lastposts as $post ) … Read more

Remove “posts” from admin but show a custom post

Doing this search, I’ve found this fine answer by Chris_O. There’s even a jQuery solution I proposed there. Anyway, the function remove_menu_page(‘edit.php’); only removes the Posts menu. But, as we learn from Chris answer, remove_menu_page(‘edit.php?post_type=athletes’); removes the Custom Post Type menu. To really block access to the URL, as we’re merely hiding the menu item, … Read more

Adding content to archive and taxonomy pages on custom post types?

First solution can be using the Settings API and create 2 fields “Products Description” and “Usage Description”, after that showing in your template that fields is easy like a: $options = get_option(‘my_theme_options’); echo $options[‘prod_description’]; // echo $options[‘usage_description’]; However, settings API is not the best part of WP core, and probably create a settings page for … Read more

Multiple custom post types under one admin menu

Just create a “placeholder” menu that you can then assign all your post types to: function wpse_226690_admin_menu() { add_menu_page( ‘Events Manager’, ‘Events Manager’, ‘read’, ‘events-manager’, ”, // Callback, leave empty ‘dashicons-calendar’, 1 // Position ); } add_action( ‘admin_menu’, ‘wpse_226690_admin_menu’ ); And then in your register_post_type calls: ‘show_in_menu’ => ‘events-manager’, Tada!

limit selection of custom taxonomies to one?

Instead of hacking it with jQuery, a more reliable solution would be to replace the meta box with your own, in PHP. Anyway, the problem is most likely with the ‘[‘ and ‘]’ characters in the selector: “input[name=tax_input[ba_locations][]]” could be rewritten as “input[name=tax_input\\[ba_locations\\]\\[\\]]” See https://stackoverflow.com/questions/2786538/need-to-escape-a-special-character-in-a-jquery-selector-string

Change the order of columns for a custom post type on the admin list page

Yes this is possible. I have changed this for the default post type, but this is also possible for a custom one. First check the codex: http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column function your_columns_head($defaults) { $new = array(); $tags = $defaults[‘tags’]; // save the tags column unset($defaults[‘tags’]); // remove it from the columns list foreach($defaults as $key=>$value) { if($key==’date’) { … Read more