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

get_terms() – unexpected ‘=>’ (T_DOUBLE_ARROW) error

This is a PHP syntax error. You’re attempting to pass an array to get_terms() but haven’t used array() or [] to make it an array. This means that => is invalid here. The code should be: public function pggggo_list_of_terms() { $terms = get_terms( [ ‘taxonomy’ => [ ‘vehicle_safely_features’, ‘vehicle_exterior_features’, ‘vehicle_interior_features’, ‘vehicle_extras’, ], ] ); return … Read more

Custom post type / Filter by letter

Assuming that you have a query result, ordered by your titles ASC and wrapped each “block” in a div with the id=”A”, etc.: There’s a PHP function to fill arrays: $aToZ = range( ‘A’, ‘Z’ ); Then you can loop through it: echo ‘<ul class=”aToZ-list”>’; foreach ( $aToZ as $char ) echo “<li class=”aToZ-el”><a href=”#{$char}” … Read more