Is meta_key used for ordering, filtering, or both?

Column meta_key is used for filtering and partially for ordering. Why partially? It is used for ordering only in combination with meta_value. Columns meta_key and meta_value are connected together like column name and column value in traditional table. For raw SQL select it would be possible to order posts by meta_key but from a practical … Read more

Custom post Query and WordPress Post Query Clash

Your code: $the_query = new WP_Query( array( ‘posts_per_page’ =>’2′, ‘paged’ => $paged )); Replace With this: global $wp_query; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array_merge( $wp_query->query, array( ‘posts_per_page’ =>’2′,’paged’ => $paged ) ); query_posts( $args ); NOTE: This code is not tested so first backup your page.

Multiple values in WP_Query : category__and

I’m little unclear from your question if the criteria has to match the Product AND the Service .. or the Product OR the Service. You can change the ‘relation’ parameter to achieve this (AND or OR) $args = array( ‘posts_per_page’ => -1, ‘cat’ => 7, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘product_customfield’, … Read more

ACF Query result in a new td (echo)

Okay, I fixed it. The final code is: <?php $args2 = array(‘post_type’ => ‘etlap’, ‘posts_per_page’ => 5, ‘post__in’ => $ids, ‘order’ => ‘post__in’); $query2 = new WP_Query($args2); ?> <tr> <td> <?php echo “Levesek” ?> </td> <?php if ($query2->have_posts()): ?> <?php while ($query2->have_posts()): ?> <?php $query2->the_post(); ?> <td> <?php $levesek = get_field(‘levesek’); $leves_adag = get_field(‘leves_adag’); ?> … Read more

How to pass a php variable to js within a template?

If you would want to pass the whole wp query you could pack it up in arrays, then json encode it and just write it out in a tag. <?php my_posts = array(); while ( have_posts() ) : the_post(); ?> <?php $properties = array( ‘title’ => get_the_title(), ‘link’ => get_the_permalink() ); $my_posts[] = $properties; ?> … Read more