WordPress Loop if/else

https://codex.wordpress.org/Class_Reference/WP_Query#Properties found_posts is the total number of posts returned by the query. example code: <?php $args = array( ‘post_type’ => ‘your_custom’ ); $custom_query = new WP_Query( $args ); if( $custom_query->have_posts() ) { $number_of_posts = $custom_query->found_posts; while( $custom_query->have_posts() ) { $custom_query->the_post(); if( $number_of_posts == 1 ) { the_content(); } else { the_excerpt(); } } wp_reset_postdata(); } … Read more

Suggestion on custom post type/ taxonomy relationship

@asis, use below on function.php to add the CPT “travel” and tamx.. under it. function travel() { $labels = array( ‘name’ => _x(‘travel’, ‘post type general name’), ‘singular_name’ => _x(‘Project’, ‘post type singular name’), ‘add_new’ => _x(‘Add New project’, ‘Project’), ‘add_new_item’ => __(‘Add New Project’), ‘edit_item’ => __(‘Edit Project’), ‘new_item’ => __(‘New Project’), ‘all_items’ => … Read more

CPT category hierarchy

If you’re trying to create a hierarchal structure with regards to custom post types you’ll need to register a custom taxonomy on a more abstract version of your desired post type. For example instead of naming your custom post type cars name it vehicle. You could then a register a hierarchical taxonomy with register_taxonomy(). In … Read more

How can I set the height of the classic editor per post-type?

One way is to adjust the TinyMCE settings: add_filter( ‘tiny_mce_before_init’, function( $settings ) { $settings[‘height’] = ‘120’; $settings[‘autoresize_max_height’] = ‘120’; return $settings; } ); and e.g. restrict further on post types and !block editor with get_current_screen(). Example: add_filter( ‘tiny_mce_before_init’, function( $settings ) { $screen = get_current_screen(); if ( $screen->is_block_editor() ) { return $settings; } if … Read more