Anyway to assign custom post types to a specific category?

you can first remove the category meta box from Actors post type edit screen like this function remove_custom_taxonomy() { remove_meta_box( ‘categorydiv’, ‘custom_post_slug’, ‘side’ ); } add_action( ‘admin_menu’, ‘remove_custom_taxonomy’ ); then create a function that will add the category on save_post function default_category($post_id){ // check autosave if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) { return $post_id; } // check … Read more

Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy

Something like this should help: <?php $post_type=”animals”; $tax = ‘vertebrate’; $tax_terms = get_terms($tax); if ( $tax_terms ) { foreach ($tax_terms as $tax_term) { $args = array( ‘post_type’ => $post_type, “$tax” => $tax_term->slug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’ => 1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); // $my_query = null; <- REMOVE THIS, … Read more

Backend search; include CPT meta?

Untested, but the following should work: add_action( ‘posts_clauses’, ‘wpse110779_filter_admin_search’, 10, 2 ); function wpse110779_filter_admin_search( $pieces, $query ){ global $wpdb; //Check if this is the main query,and is a search on the admin screen if( $query->is_search() & $query->is_admin() && $query->is_main_query() ){ //Collect post types & search term $post_types = $query->get(‘post_type’); $search = $query->get(‘s’); //Check if query … Read more

WordPress monthly archive links result in 404

It looks like you need to add your news custom post type to the query for archive pages (I had the same problem). Codex: custom post types to query Add this code to your functions // Show posts of ‘post’, and ‘news’ post types on archive page add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ ); function add_my_post_types_to_query( $query ) … Read more

CSS for Custom Post Types

In your post loop, you could always set a class name that is the equivalent to the slug of the custom post type and then adjust the css accordingly. You’d need to add the post_class() function to the html element containing each post. For this option, you’ll want to get the post type first: <?php … Read more

Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug

Try changing the page’s slug to something else and changing your post type registration to this: $args = array( ‘labels’ => $labels, ‘public’ => true, ‘publicly_queryable’ => true, ‘has_archive’ => true, ‘show_ui’ => true, ‘rewrite’ => array(‘slug’ => ‘properties’, ‘with_front’ => false), ‘query_var’ => true, ‘capability_type’ => ‘post’, ‘hierarchical’ => false, ‘show_in_nav_menus’ => false, ‘menu_position’ … Read more

WordPress Gutenberg-Block with ESNext (withState, withSelect)

Okay guys, I’ve got a solution: import {withSelect} from ‘@wordpress/data’; import {SelectControl} from “@wordpress/components”; import ReactSpinner from ‘react-bootstrap-spinner’ import ServerSideRender from ‘@wordpress/server-side-render’; const MySelectControl = ( ({chart, setAttributes, …props}) => ( <SelectControl label=”Bitte wählen Sie ein Diagramm aus: ” value={chart ? parseInt(chart) : 0} options={props.options} onChange={(chart) => { setAttributes({ chart: chart }); }} /> ) … Read more