How to hide home title on pages and posts?

If I follow what you’re explaining correctly, try adding a document title filter to the functions.php theme file. (NB: setting to only change post and pages. Search, Archive, etc, will keep original title. You can always modify accordingly.) *** EDIT: added a filter for older themes that uses wp_title. add_filter(‘wp_title’, set_custom_page_title, 99999); //NB:backward compatibility with … Read more

CPT Template Option to Top

You could hook into theme_{$post_type}_templates and add an identical “default” option at the end: add_action(‘theme_page_templates’, ‘wpse_296283_theme_page_templates’); function wpse_296283_theme_page_templates($post_templates){ $post_templates[‘default’] = “Default Template”; return $post_templates; } Then you’d hide the first one with CSS: add_action(‘admin_head’ ‘wpse_296283_admin_head’); function wpse_296283_admin_head(){ ?> <style>#page_template option:first-child {display: none;}</style> <?php }

Adding custom shortcode to page leads to page without styling

Shortcodes need to return their values, but the_content() echoes the post content. So you have two options. First is to capture all output and then return it at the end: ob_start(); // Start capturing output; while( $loop->have_posts() ) { $loop->the_post(); the_content(); }; wp_reset_postdata(); return ob_get_clean(); // Return captured output; That will be the cleanest way … Read more

See the process of creating a taxonomy and tell me where I made a mistake

You shouldn’t be doing this: $searchProductsByCategory = [ ‘posts_per_page’ => 1, ‘post_type’ => ‘product’, ‘ignore_sticky_posts’ => 1, ‘orderby’ => ‘id’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘product_category’, ‘terms’ => get_queried_object_id() ] ] ]; $foundProducts = new WP_Query($searchProductsByCategory); The whole point of taxonomy-product_category.php is that posts for the current category have already been queried. This is … Read more

How to Create Short Code Using Custom Post type

Try this /** * Register all shortcodes * * @return null */ function register_shortcodes() { add_shortcode( ‘listing’, ‘shortcode_mostra_produtos’ ); } add_action( ‘init’, ‘register_shortcodes’ ); /** * Produtos Shortcode Callback * * @param Array $atts * * @return string */ function shortcode_mostra_produtos( $atts ) { global $wp_query, $post; $atts = shortcode_atts( array( ‘type’ => ” ), … Read more

Custom post type efficiency

As the reading of the database is lightning fast, I would not worry too much about it. You have got a few points to consider: If you want to have all your metavalues queryable by the standard wordpress queries, you have to save them into different records. If you have a big, standardized set of … Read more