Advise on Custom Taxonomies and Structure

That’s how you resister taxonomy. This will add author as taxonomy <?php /** * @uses Register Book Author Taxonomy * @uses Adds query vars * @author Nirpendra Patel * @return void **/ function reg_tax_author() { $authors = array( ‘name’ => _x( ‘Authors’, ‘Taxonomy plural name’, ‘b_thebookstore’ ), ‘singular_name’ => _x( ‘Author’, ‘Taxonomy singular name’, ‘b_thebookstore’ … Read more

How to get ‘Products’ on home page?

Here’s a product loop I found: <ul class=”products”> <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); woocommerce_get_template_part( ‘content’, ‘product’ ); endwhile; } else { echo __( ‘No products found’ ); } wp_reset_postdata(); ?> </ul><!–/.products–> Maybe … Read more

Passing postid of Testimonial Custom Post in Shortcode Parameter

Well, maybe you shouldn’t set $args[‘posts id’] as this is not a supported argument for the get_posts function and instead use the “posts__in” argument or instead switch to the “get_post” function if you get the id parameter. Also, i’m not quite sure but i think you have to use quotes in the shortcode. So your … Read more

Get all post from custom post type in custom taxonomy

i think you posted the different code earlier. But if this is the code you are using right now then you should so this $slide = new wp_query( array ( ‘post_type’ => ‘banner’ , ‘tax_query’ => array( array( ‘taxonomy’ => ‘country’, ‘field’ => ‘name’, ‘terms’ => ‘algeria’ ), ), ‘meta_query’ => array( ‘relation’ => ‘AND’, … Read more

Wp-theme Development

Please check how the Loop works, followed by the correct way to instantiate a new Query. Try this: <?php // The correct way to create a new Query $newquery = new WP_Query( array( ‘category_name’ => ‘notice’, ‘posts_per_page’ => 1 )); // Check if query found posts, then start the Loop if($newquery->have_posts) : while ($newquery->have_posts() ) … Read more

wordpress custom post type shows other cpt posts in admin menu

i don’t know why but the problem solved after i deleted the following question code from my function.php file // 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 ) { if ( is_archive() && $query->is_main_query() ) $query->set( ‘post_type’, array( ‘post’, ‘news’ ) ); return $query; … Read more

How to loop through a custom post type using a shortcode and output each element in the loop using shortcodes

Probably you need to create a shortcode with parameters. You should have different parameters for font size, color, bold, underline or anything else. The user should insert a value for each of these parameters in the shortcode. You can find what you need here https://developer.wordpress.org/plugins/shortcodes/shortcodes-with-parameters/ It is a little tricky though because you must check … Read more