Categories
CMS Mastering Development Wordpress

Sorting not working with get_posts

I have been looking at this for hours but can’t get it to work. $newsItems2 = get_posts([ “post_type” => “post”, “post_status” => “publish”, “posts_per_page” => 3, “orderby” => “date”, “order” => “DESC”, ‘meta_query’ => [ [ ‘key’ => ‘news__type’, ‘value’ => ‘general’, ‘compare’ => ‘=’ ] ] ]); The query works but it refuses to […]

Categories
CMS Mastering Development Wordpress

Sorting not working with get_posts

I have been looking at this for hours but can’t get it to work. $newsItems2 = get_posts([ “post_type” => “post”, “post_status” => “publish”, “posts_per_page” => 3, “orderby” => “date”, “order” => “DESC”, ‘meta_query’ => [ [ ‘key’ => ‘news__type’, ‘value’ => ‘general’, ‘compare’ => ‘=’ ] ] ]); The query works but it refuses to […]

Categories
CMS Mastering Development Wordpress

Shortcode for custom query not returning results when attributes are added

I’m trying to build a shortcode that will allow the user to choose what category is displayed and how many posts will show. The shortcode worked fine until I added the ‘tax_query’ add_shortcode( ‘latest_post’, ‘latest_post_query_shortcode’ ); function latest_post_query_shortcode( $atts ) { $atts = shortcode_atts( array( ‘post_per_page’ => ”, ‘category’ => ”, ), $atts ); $args […]

Categories
CMS Mastering Development Wordpress

How to display child category name in WP_Query loop?

I have simple wp_query <?php $the_query = new WP_Query( array( ‘category_name’ => “company”, ‘posts_per_page’ => 3, )); if ( $the_query->have_posts() ) : ?> <div class=”article-list–horizontal article-list–horizontal__4″> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <article class=”is-article is-article–small is-article–grey”> <div class=”article-description”> <span class=”is-category”><?php the_category(); ?></span> <h3 class=”is-title”> <?php the_title(); ?> </h3> <div class=”is-excerpt”> <?php the_excerpt(); ?> […]

Categories
CMS Mastering Development Wordpress

Products are repeated in Woocommerce category

I just created a “special” category for a product type. But the products are repeated by three. Thanks in advance. Link: https://aventurasport.cl/product-category/parapente/ <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 3, ‘product_cat’ => ‘parapente’ ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> <li class=”product”> <div class=”todooo”> […]

Categories
CMS Mastering Development Wordpress

How can I get the content of the current page in my loop while merging post-type

I made a loop which is loading post-type. But while it is loading basic post and post-type, it is not loading the main content of the page. I am searching for a way to load the current page content while loading my post-type. How can I do that ? global $wp_query; $args = array_merge( $wp_query->query, […]

Categories
CMS Mastering Development Wordpress

create custom shortcode wp and put php code in

i use ACF plugin and i want put this query in shortcode. but i have a problem. add_shortcode(‘pishnahadi’ , ‘kn_inline_related’); function kn_inline_related( $atts ) { $html= ”; $posts = get_field(‘pishnahadi’, false, false); $loop = new WP_Query(array(‘post_type’ => ‘news’, ‘posts_per_page’ => 3, ‘post__in’ => $posts, ‘post_status’ => ‘publish’, ‘orderby’ => ‘post__in’, ‘order’ => ‘ASC’ )); if($loop->have_posts()) […]

Categories
CMS Mastering Development Wordpress

Custom post taxonomies as tax_query terms?

I have these two custom post types called “product” and “reference”. On “references” I have attached a custom taxonomy called “product_reference” which I use to specify which products the references are related to. On the “product” custom posts I have attached a custom module called “module-relevant-references” for fetching reference-posts relevant to the product. This might […]

Categories
CMS Development Wordpress

Combine meta query and give a specific meta query a higher priority

there is this loop which sorts by the date. But I want to throw in a specific meta key for a even higher priority. The meta_key “high_prio” should move it to the top of the sorting. (I hope that makes sence). Let’s speak some code: $loop = new WP_Query( array( ‘post_type’ => ‘event’, ‘posts_per_page’ => […]

Categories
CMS Development Wordpress

Combine meta query and give a specific meta query a higher priority

there is this loop which sorts by the date. But I want to throw in a specific meta key for a even higher priority. The meta_key “high_prio” should move it to the top of the sorting. (I hope that makes sence). Let’s speak some code: $loop = new WP_Query( array( ‘post_type’ => ‘event’, ‘posts_per_page’ => […]