Custom Loop for Custom Post Type

There are couple of issues in your query. There is not parameter named category. You can use these following. cat (int) – use category id. category_name (string) – use category slug (NOT name). category__and (array) – use category id. category__in (array) – use category id. category__not_in (array) – use category id. If you need your … Read more

Get list of registered custom post types

Your code looks good. However, you can try the followoing codes to get all custom posts $args = array( ‘public’ => true, ‘_builtin’ => false, ); $output=”names”; // names or objects, note names is the default $operator=”and”; // ‘and’ or ‘or’ $post_types = get_post_types( $args, $output, $operator ); foreach ( $post_types as $post_type ) { … Read more

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