Tax_query not working in wordpress. how to solve? - php

I made a page template where i can filter some posts. If u do a normal WP_Query everything is fine. But if i use the tax_query it displays no posts.
for registering the post types and taxonomies i use the plugin 'cptui'.
The regular WP_Query request:
$query = new WP_Query(array(
'post_type' => $post->post_name,
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => $paged,
));
if(!$_POST) { //If not filtered ... then show all
if($query->have_posts()): while ($query->have_posts()) : $query->the_post();
echo "<a href='".get_post_permalink()."'><div style='box-shadow: 0 0 15px 0 rgba(0,0,0,.05); padding: 50px; width: 100%; margin: 5px; '>";
echo "<h5>" . $query->post->post_title . "</h5>";
echo "<p>" . get_field( "plaats" ) . '-' . get_term(get_field('dienstverbanden'))->name . "</p>";
echo "</div></a>";
endwhile; endif;
}
I read other posts and they said i could use the php echo $GLOBALS['query']->request; to see what the mysql query is.
My query is:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1 = 1
AND wp_posts.post_type = 'vacature'
AND ((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.post_date DESC
LIMIT 6, 6
and now the request with the tax_query.
The tax_query WP_Query request:
$query = new WP_Query(array(
'post_type' => $post->post_name,
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'provincie',
'field' => 'slug',
'terms' => 'noord-brabant',
'include_children' => 0
),
),
));
if(!$_POST) { //If not filtered ... then show all
if($query->have_posts()): while ($query->have_posts()) : $query->the_post();
echo "<a href='".get_post_permalink()."'><div style='box-shadow: 0 0 15px 0 rgba(0,0,0,.05); padding: 50px; width: 100%; margin: 5px; '>";
echo "<h5>" . $query->post->post_title . "</h5>";
echo "<p>" . get_field( "plaats" ) . '-' . get_term(get_field('dienstverbanden'))->name . "</p>";
echo "</div></a>";
endwhile; endif;
}
The query I get now is:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
WHERE 1 = 1
AND (wp_term_relationships.term_taxonomy_id IN (3))
AND wp_posts.post_type = 'vacature'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
LIMIT 6, 6
and I get no posts back.
Do you know any solution for this?
Full code of the template:
<div id="page-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
<?php
global $post;
$paged = ( get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query(array(
'post_type' => $post->post_name,
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'provincie',
'field' => 'slug',
'terms' => array( 'noord-brabant')
)
)
));
// echo $GLOBALS['query']->request;
if(!$_POST) { //If not filtered ... then show all
if($query->have_posts()): while ($query->have_posts()) : $query->the_post();
echo "<a href='".get_post_permalink()."'><div style='box-shadow: 0 0 15px 0 rgba(0,0,0,.05); padding: 50px; width: 100%; margin: 5px; '>";
echo "<h5>" . $query->post->post_title . "</h5>";
echo "<p>" . get_field( "plaats" ) . '-' . get_term(get_field('dienstverbanden'))->name . "</p>";
echo "</div></a>";
endwhile; endif;
}
else { //now its filtered
$null = true;
if($query->have_posts()): while ($query->have_posts()) : $query->the_post();
$filterconditions = []; //hier komen alle filtercondities in
$keys = array_keys($_POST);
foreach($keys as $key) {
if($_POST[$key] == "on") {
$filter = explode("_",$key);
$field = $filter[0];
$filter = $filter[1];
$taxonomy = get_field( $field );
$term = get_term_by('term_id', $taxonomy, $field);
array_push($filterconditions, '"' . $filter . '"' . '==' . '"' . $term->name . '"');
}
};
$filterconditions = implode('&&', $filterconditions);
// echo $filterconditions;
if(eval("return $filterconditions;")) {
$null = false;
echo "<a href='".get_post_permalink()."'><div style='box-shadow: 0 0 15px 0 rgba(0,0,0,.05); padding: 50px; width: 100%; margin: 5px; '>";
echo "<h5>" . $query->post->post_title . "</h5>";
echo "<p>" . get_field( "plaats" ) . '-' . get_term(get_field('dienstverbanden'))->name . "</p>";
echo "</div></a>";
}
endwhile; endif;
if($null) {
echo "Sorry, er zijn geen vacatures gevonden met deze filters";
}
}
$total_pages = $query->max_num_pages;
if ($total_pages > 1 && !$null) {
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
wp_reset_query();
?>
</div>

$args=array(
'post_type' => 'your_post_type',
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'DESC',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'provincie',
'field' => 'slug',
'terms' => array( 'noord-brabant')
)
)
);
$result = new WP_Query( $args );
// The Loop
if ( $result->have_posts() ) {
while ( $result->have_posts() ) {
$result->the_post();
// this is your loop
}
} else {
// nothing
}
Can try above code

You can get simple custom post type list using below code:
$args = array(
'post_type' => 'services',
'post_status' => 'publish',
'posts_per_page' => 6,
'orderby’ => 'title',
'order’ => 'ASC',
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
print the_title();
the_excerpt();
endwhile;
wp_reset_postdata();
Place your custom post type name to retrieve post and change the while loop according to your need

Ok can you use get post method instead of WP Query:
$posts_array = get_posts(
array(
'posts_per_page' => 6,
'post_type' => $post->post_name, // Get POST TYPE FROM $GLOBAL POST
'tax_query' => array(
array(
'taxonomy' => 'provincie',
'field' => 'slug',
'terms' => 'noord-brabant',
)
)
)
);

Related

Sort posts by ACF date and add title for each month

I'm trying to create an archive page for my blog posts that is sorted by the date that is added through an ACF datepicker-field.
This is what I have so far:
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_key' => 'datum_artikel',
'meta_value' => date('Ymd',strtotime("today")),
'meta_compare' => '<='
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
echo "<div class='posts'>";
while ( $query->have_posts() ) {
$query->the_post();
$f = get_fields();
$link = ($f['bericht_doorverwijzen'] ?? '' ? $f['bericht_doorverwijzen'] : get_the_permalink());
$img_id = get_post_thumbnail_id();
$date = $f['datum_artikel'];
echo "<div class='post w-1/3'>";
echo "<div class='postWrapper'>";
if(!empty($img_id)) {
$img = Images::get_image_resized($img_id, 397, 230, true);
echo "<a href='".$link."' title='Ga naar ".get_the_title()."'>";
echo '<picture class="img">';
echo '<img src="'.$img[0].'" alt="'.get_post_meta($img_id, '_wp_attachment_image_alt', true).'"/>';
echo '</picture>';
echo "</a>";
}
echo "<div class='content'>";
echo "<h2><a href='".$link."' title='Ga naar ".get_the_title()."'>".get_the_title()."</a></h2>";
if(!empty($date)) {
echo "<p class='date'>". $date ."</p>";
}
echo the_excerpt_max_charlength($charlength = 130);
echo "</div>";
echo "</div>";
echo "</div>";
}
echo "</div>";
}
wp_reset_postdata();
I found some examples online but none of them seem to work with my code. How can I add the name of the month between the posts when the month changes and can I create an extra navigation with all the months and an anchor so it jumps to the right posts?
I found another example online that seems to do what what I need:
$query = new WP_Query( array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_key' => 'datum_artikel',
'orderby' => 'meta_value',
'order' => 'DESC',
) );
if ( $query->have_posts() ) {
$current_header = "";
echo "<div class='posts'>";
while ( $query->have_posts() ) {
$query->the_post();
$f = get_fields();
$date = $f['datum_artikel'];
$temp_date = get_post_meta( get_the_ID(), 'datum_artikel', true);
$pretty_month = date_i18n("F Y", strtotime($temp_date));
if ($pretty_month != $current_header) {
$current_header = $pretty_month;
echo "<h2>". $pretty_month ."</h2>";
}
$link = ($f['bericht_doorverwijzen'] ?? '' ? $f['bericht_doorverwijzen'] : get_the_permalink());
$img_id = get_post_thumbnail_id();
echo "<div class='post w-1/3'>";
echo "<div class='postWrapper'>";
if(!empty($img_id)) {
$img = Images::get_image_resized($img_id, 397, 230, true);
echo "<a href='".$link."' title='Ga naar ".get_the_title()."'>";
echo '<picture class="img">';
echo '<img src="'.$img[0].'" alt="'.get_post_meta($img_id, '_wp_attachment_image_alt', true).'"/>';
echo '</picture>';
echo "</a>";
}
echo "<div class='content'>";
echo "<h2><a href='".$link."' title='Ga naar ".get_the_title()."'>".get_the_title()."</a></h2>";
if(!empty($date)) {
echo "<p class='date'>". $date ."</p>";
}
echo the_excerpt_max_charlength($charlength = 130);
echo "<a href='".$link."' title='Ga naar ".get_the_title()."' class='link'>Lees meer</a>";
echo "</div>";
echo "</div>";
echo "</div>";
}
echo "</div>";
}
wp_reset_postdata();
$today = date("Y/m/j");
$args = (array(
'post_type' => 'post',
'posts_per_page' => -1,
'meta_key' => 'datum_artikel',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'datum_artikel',
'value' => $today,
'compare' => '<=',
'type' => 'CHAR'
)
)
));
$query = new WP_Query($args);

How do I apply my filter only to one store/url?

I've been struggling applying filters to my woocommerce shop. I have a website with multiple store pages and I've found a filter to only shop products published within the last 30 days. I want this filter to only apply to the 'new releases' shoppage, not to the whole website. Currently it's filtering everything, so even pages created before last month won't appear for example.
How do I make sure this filter is only applied to 1 store? Can I apply an IF statement and check current URL before the filter works or something?
Any help is appreciated.
Filter: (from https://www.sitepoint.com/community/t/show-latest-30-days-products-in-woocommerce/258276)
function baba_recent_products() {
//return 'This is where the recent products should show up if I get the shortcode working. ';
global $woocommerce_loop;
extract( shortcode_atts( array(
'per_page' => '48',
'columns' => '2',
'orderby' => 'date',
'order' => 'desc'
), $atts ) );
$meta_query = WC()->query->get_meta_query();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page,
'orderby' => $orderby,
'order' => $order,
'meta_query' => $meta_query
);
ob_start();
$products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $args, $atts ) );
$woocommerce_loop['columns'] = $columns;
if ( $products->have_posts() ) : ?>
<?php woocommerce_product_loop_start(); ?>
<?php while ( $products->have_posts() ) : $products->the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php endif;
wp_reset_postdata();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
add_shortcode( 'baba_recent_products', 'baba_recent_products' );
function filter_where($where = '') {
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
function baba_recent_products() {
//return 'This is where the recent products should show up if I get the shortcode working. ';
global $woocommerce_loop;
extract( shortcode_atts( array(
'per_page' => '48',
'columns' => '2',
'orderby' => 'date',
'order' => 'desc'
), $atts ) );
$meta_query = WC()->query->get_meta_query();
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page,
'orderby' => $orderby,
'order' => $order,
'meta_query' => $meta_query
);
ob_start();
$products = new WP_Query( apply_filters( 'woocommerce_shortcode_products_query', $args, $atts ) );
$woocommerce_loop['columns'] = $columns;
if ( $products->have_posts() ) : ?>
<?php woocommerce_product_loop_start(); ?>
<?php while ( $products->have_posts() ) : $products->the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php endif;
wp_reset_postdata();
return '<div class="woocommerce columns-' . $columns . '">' . ob_get_clean() . '</div>';
}
add_shortcode( 'baba_recent_products', 'baba_recent_products' );
function filter_where($where = '') {
global $post;
if($post->ID === /*Page ID as int here*/){
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
}
return $where;
}
add_filter('posts_where', 'filter_where');

How can I add navigation links below WordPress posts using PHP?

I am working on a PHP/WordPress-based website and would like to add 3 navigation links (one previous link and 2 next links) below each post of a custom post type. The links should look like this:
[prev] [next] [next]
My current code is below, but it is not working at the moment. How can I get this code to display the desired links?
$currentID = get_the_ID();
$args = array (
'post_type' => array( 'guides' ),
'post_status' => array( 'publish' ),
'nopaging' => false,
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => 3,
'ignore_sticky_posts' =>true,
'post__not_in' => array($currentID)
);
$guides_query = new WP_Query( $args );
if ( $guides_query->have_posts() ) {
echo '<div class="grid-container nxt-article">';
echo '<div class="nxt-article-heading"><h2>Next article</h2></div>';
while ( $guides_query->have_posts() ) {
$guides_query->the_post();
echo '<div class="nxt-article-box"><div class="nxt-article-box-shadow">';
echo '<a class="nxt-article-link" href="'.get_the_permalink().'"></a>';
$gear_category = get_field('gear_category', $products->ID);
if ($gear_category) :
echo '<div class="g_pre_title" style="color:#fff;position:absolute;left:30px;top:25px;">'.$gear_category[0].'</div>';
endif;
echo '<div>';
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'post_grid_image' );
}
echo '</div><div style="padding: 0px 30px 30px 30px;"><div class="nxt-article-box-title">'.get_the_title().'</div>';
$intro_section = get_field('introduction_section', $post->ID);
if( $intro_section ) :
echo '<div class="pg_excerpt" style="height:85px;overflow:hidden;">'.wp_trim_words( $intro_section['wysiwyg'], 32, '...' ).'</div>';
endif;
echo '</div></div></div>';
}
echo '<div style="text-align:center;"><a class="ml_button_style" href="">Show ALL GUIDES</a></div>';
echo '</div>';
} else {
}
wp_reset_postdata();

Using ajax to create a filter selector for WooCommerce products

I want to create an ajax filter selector for WooCommerce products, without any plugins.
But I don't know how to approach this problem.
I have this list of product with the dropdown to select the kind of filter:
I use this code to show the list:
<?php wc_get_template_part( 'list', 'product' ); ?>
I know that the <div> class that I have to replace is '.products', but I have to change the $post to change the attribute by low price , hight price or alphabetical orden, and I don't find any solution.
This is my function to change the div when I select a element when I change the dropdown
$('#filter_paradise').change ->
valor = $('#filter_paradise option:selected').val()
changepost(valor)
return
when I change the dropdown I call changepost function with the select value, this function replace the div with the new value, but before that, call to filter_product function
changepost = (valor) ->
value = valor
request = $.ajax(
url: ajax_object.ajax_url
method: 'POST'
data:
opc: value
action: 'filter_product'
dataType: "json"
success: (html, data) ->
#$('.products').replaceWith(html);
console.log 'change'
return
error: (errorThrown) ->
console.log errorThrown
return
)
return
This function is in function.php, in this function I have there values, the country, the category and the value select by the filter I need this values to create the query and order by low price, hight price or alphabetical
function filter_product(){
$last_uri = explode('/', $_SERVER['HTTP_REFERER']);
$country = $last_uri[6];
$getcategoria = explode('=',$last_uri[7]);
$categoria = $getcategoria[1];
$args = null;
echo json_encode($categoria);
exit();
}
Before to $('.products').replaceWith(html); in changepost function
I have to change the $args in:
$wp_query = new WP_Query( $args );
The div that I have to replace is in <?php wc_get_template_part( 'list', 'product' ); ?> this partial is in archive-product.php this view is like this.
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-xs-12">
<div class="elementos_lista">
<ul>
<li>
<?php wc_get_template_part( 'list', 'product' ); ?>
</li>
</ul>
</div>
</div>
<?php //wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile; // end of the loop. ?>
<div class="map_paradise"></div>
and before to execute the loop I have to get a new $args to the query with the new parameters, order by price or alphabetical.
What I am doing wrong?
Is there an other way to do that?
Any idea to point me on the right direction is welcome.
Thanks.
Finally I create a Filter, this is my solution
I create my dropdown
<div class="filter_paradise">
<div class="col-xs-12">
<select id="filter_paradise" class="form-control">
<option value="0">Alphabetical</option>
<option value="1">High Price</option>
<option value="2">Low Price</option>
</select>
</div>
</div>
When my dropdown change I call this function
$('#filter_paradise').change ->
valor = $('#filter_paradise option:selected').val()
changepost(valor)
return
changepost = (valor) ->
value = valor
request = $.ajax(
url: ajax_object.ajax_url
method: 'POST'
data:
opc: value
action: 'filter_product'
dataType: "json"
success: (html, data) ->
$('.products').replaceWith(html);
console.log 'change'
return
error: (errorThrown) ->
console.log errorThrown
return
)
return
and finally I call a function filter_product in function.php to change my div
function filter_product(){
$select_opc = $_POST['opc'];
$last_uri = explode('/', $_SERVER['HTTP_REFERER']);
$country = $last_uri[4];
$getcategoria = explode('=',$last_uri[5]);
$categoria = $getcategoria[1];
// var_dump($last_uri);
// var_dump($categoria);
// var_dump($country);
wp_reset_query();
if (!empty($categoria)):
switch ($select_opc) {
case 0:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'product_cat' => $categoria,
'tax_query' => array(
array(
'taxonomy' => 'pa_country',
'terms' => $country,
'field' => 'name',
//'operator' => 'IN'
)
)
);
break;
case 1:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '_price',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'product_cat' => $categoria,
'tax_query' => array(
array(
'taxonomy' => 'pa_country',
'terms' => $country,
'field' => 'name',
//'operator' => 'IN'
)
)
);
break;
case 2:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '_price',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'product_cat' => $categoria,
'tax_query' => array(
array(
'taxonomy' => 'pa_country',
'terms' => $country,
'field' => 'name',
//'operator' => 'IN'
)
)
);
break;
default:
# code...
break;
}
else:
switch ($select_opc) {
case 0:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'product_cat' => $country
);
break;
case 1:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '_price',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'product_cat' => $country
);
break;
case 2:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '_price',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'product_cat' => $country
);
break;
default:
# code...
break;
}
endif;
$the_query = new WP_Query( $args );
$salida = '<ul class="products">';
$salida .= '<div class="col-xs-12">';
$salida .= '<div class="elementos_lista">';
$salida .= '<ul>';
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
$salida .= '<li>';
$product_thumbnail_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail');
$url = get_permalink();
$salida .='<a href="'. get_permalink() .'">';
$salida .= '<div class="row list_product_paradise">';
if ($product_thumbnail_url):
$salida .= '<div class="col-xs-2 image_product_thumbnail">';
$salida .= '<img src="'. $product_thumbnail_url[0] .'" class="img-responsive" alt="'.get_the_title() .'">';
$salida .= '</div>';
$salida .= '<div class="product_cat col-xs-7">';
$salida .= get_the_title();
$salida .= '</div>';
else:
$salida .= '<div class="product_cat col-xs-9">';
$salida .= get_the_title();
$salida .= '</div>';
endif;
$salida .='<div class="total_items col-xs-3">';
$salida .= get_post_meta( get_the_ID(), '_regular_price', true);
$salida .= '</div>';
$salida .= '</div>';
$salida .= '</a>';
$salida .= '</li>';
endwhile;
endif;
$salida .= '</ul>';
$salida .= '</div>';
$salida .= '</div>';
$salida .= '</ul>';
$salida .= '<div class="map_paradise"></div>';
echo $salida;
exit();
}
add_action( 'wp_ajax_filter_product', 'filter_product' ); // If called from admin panel
add_action( 'wp_ajax_nopriv_filter_product', 'filter_product' ); // If called from front end

Display posts that have two taxonomies in Wordpress wp_query

I'm looking to display posts if they match two separate taxonomies, which are bridal accessories free and glasgow.
At the moment I can get the wp_query loop code below to show all the results from both taxonomies; however I need the loop to display only the posts that have both the categories selected.
<?php
/**
* Create a new WP_Query
* Set $wp_query object to temp
* Grab $paged variable so pagination works
*/
?>
<?php
global $wp_query; $post; $post_id = $post-> ID;
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
rewind_posts();
$temp = $wp_query;
$wp_query = NULL;
$post_type = 'place'; // change this to the post type you want to show
$show_posts = '30'; // change this to how many posts you want to show
$category_name = 'bridal-accessories-free,special-offer' // change this to the category name you need
?>
<?php $wp_query = new WP_Query( 'placecategory=' . $category_name . '&post_type=' . $post_type . '&posts_per_page=' . $show_posts . '&paged=' . $paged ); ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<p style="font-size: 15px; margin-bottom: 10px;"><span style="font-weight: normal; margin-right: 5px; text-transform: uppercase; color: #a5cc8e;"><?php the_title(); ?></span> <span style="margin-right: 5px; color: #000;"><?php echo get_post_meta($post->ID,'geo_address',true);?></span> <?php $contact = stripslashes(get_post_meta($post->ID,'contact',true));
if($contact && get_option('ptthemes_contact_on_detailpage') == 'Yes') { ?><?php echo PHONE.": "; ?> <?php echo $contact;?><?php } ?>
<?php endwhile; ?></p>
<?php wp_reset_query(); ?>
</div>
If this can be done, is there anyway to pass the loop query variables into the url. We need this to create a link to the results.
Thanks in advance!
Please try this code
$args = array(
'post_type' => array('post','reviews'),
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'category',
'terms' => 'android',
'field' => 'slug'
),
array(
'taxonomy' => 'review_category',
'terms' => 'android',
'field' => 'slug'
),
)
);
query_posts($args);

Categories