I've an unique situation where I need to display same comments for 3 different posts. This 3 different posts are obviously linked together in DB. So what I need to do is to force use of 1 post ID for all languages to submit comment and retrieve it... instead of using 3 diff IDs I need to use 1 and stick to it.
I've $current_post_duplicate_id which is 9 for all 3 translated posts.
If I submit comment on original post which is originally post_ID 9 all works fine, I see comment and it gets submited. But when I switch to translated version nothing is displayed, but I'm forcing get_comments to use id 9 for displaying and submiting comments through $current_post_duplicate_id, so what is happening? why is not this working??
I cannot figure out what is happening, I figured some guru here could give me a hint.
<?php
//Uniting comments in all languages by setting default language for comments en in this case
$current_post_duplicate_id = icl_object_id (get_queried_object_id(), 'tribe_events', false, 'en');
?>
<div id="eventattend">
<?php if ('open' == $post->comment_status) : ?>
<span><?php _e('Are you intersted?'); ?></span>
<?php if ( $user_ID ) : ?>
<?php
$usercomment = get_comments( array( 'user_id' => $current_user->ID, 'post_id' => $current_post_duplicate_id ) );
if ( 1 <= count( $usercomment ) ) {
?>
<form method="post" action="">
<a class="eventno" href="javascript:;" onclick="parentNode.submit();"><?php _e('No'); ?></a>
<input type="hidden" name="delmycom" value="1" />
<?php
//
$delete_my_event_interest = $_POST['delmycom'];
//
if ( isset ($delete_my_event_interest) ) {
$current_user_comment = get_comments( array(
'post_id' => $current_post_duplicate_id,
'user_id' => get_current_user_id(),
'number' => 1,
'status' => 'approve',
'type' => 'comment'
) );
wp_delete_comment( $current_user_comment[0]->comment_ID );
}
//
?>
</form>
<?php } else { ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $current_post_duplicate_id); ?>
<input type="hidden" name="comment" value="I'm attending this Event!" />
<a class="eventyes" href="javascript:;" onclick="parentNode.submit();"><?php _e('Yes'); ?></a>
</form>
<?php } ?>
<?php else : ?>
<a class="eventyes loginosx" href="#"><?php _e('Yes'); ?></a>
<?php _e('*You need to be loged in to say YES.'); ?>
<?php endif; ?>
<?php endif; // if you delete this the sky will fall on your head ?>
<div class="clearfloat"></div><!-- Very Important -->
<!-- End #eventattend --></div>
<!-- End #eventsingle --></div>
<ul class="sidebarlists" id="interestedlist">
<li>
<h2><?php _e('Who\'s interested so far?'); ?> (<?php comments_number( '0', '1', '%' ); ?>)</h2>
<ul>
<?php
$recent_comments = get_comments( array(
'post_id' => $current_post_duplicate_id,
'number' => 25,
'status' => 'approve',
'type' => 'comment',
'order' => 'ASC'
) );
foreach ($recent_comments as $comment) {
?>
<li id="attendee-<?php echo $comment->comment_ID; ?>">
<?php echo get_avatar( $comment->comment_author_email, $size = '50', $alt = $comment->comment_author.' is attending this event' ); ?>
<span><?php echo $comment->comment_author; ?></span>
</li>
<?php
}
?>
</ul>
</li>
<!-- End #sidebarlists --></ul>
use this
<?php $comments = get_comments(array('post_id' => 1)); ?>
You can also pass the following parameters
<?php $defaults = array(
'author_email' => '',
'ID' => '',
'karma' => '',
'number' => '',
'offset' => '',
'orderby' => '',
'order' => 'DESC',
'parent' => '',
'post_id' => 0,
'post_author' => '',
'post_name' => '',
'post_parent' => '',
'post_status' => '',
'post_type' => '',
'status' => '',
'type' => '',
'user_id' => '',
'search' => '',
'count' => false,
'meta_key' => '',
'meta_value' => '',
'meta_query' => '',
); ?>
Related
I'm facing problem in my custom post pagination. The custom pagination is work fine on single page with same code but it is not working on another page.
I have updated the permalink many times but nothing happen. I also update .htaccess file.
My source code listed here...
<div id="home" class="tab-pane fade in active">
<p class="main_dv"><?php
//$count=1;
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$data= new WP_Query(array(
'post_type'=>'software',// your post type name
'category_name' => 'general_software', // your category name
'posts_per_page' => 5, // post per page
'paged' => $paged,));
if($data->have_posts()) :
while($data->have_posts()) : $data->the_post();?>
<div class="testcustompost1">
<div class="pst_div">
<div class="thumb">
<?php the_post_thumbnail();?>
</div>
<div class="title_des">
<div class="title">
<?php the_title();?>
</div>
<div class="description">
<?php the_content();?>
</div>
<div class="downlod_btn">
<button class="btn"> Download </button>
</div>
</div>
</div>
</div>
<?php //$count++;
endwhile;
echo '<div class="paginat_design">';
$total_pages = $data->max_num_pages;
if ($total_pages > 1){
$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 »'),
));
}
echo '</div>'?>
<?php else :?>
<?php _e('404 Error: Not Found', ''); ?>
<?php endif; ?>
<?php wp_reset_postdata();?>
</p>
</div>
404 Not found error
You should try this:
<?php
/**
* Looping through the content
*/
$page = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$data = new WP_Query (array(
'post_type'=>'software',
'category_name' => 'general_software',
'posts_per_page' => 5,
'page' => $page
)); ?>
<?php while ($data -> have_posts()) : $data -> the_post(); ?>
<!-- Your html code here -->
<?php endwhile; ?><?php wp_reset_query(); ?><?php wp_reset_postdata();
?>
Here is the pagination part:
<?php
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $data->max_num_pages,
'current' => max( 1, get_query_var( 'page' ) ),
'format' => '?page=%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => sprintf( '<i></i> %1$s', __( 'Previous Page', 'text-domain' ) ),
'next_text' => sprintf( '%1$s <i></i>', __( 'Next Page', 'text-domain' ) ),
'add_args' => false,
'add_fragment' => '',
) );
?>
Let me know if it is this help you. If not, try to change the value from paged to page.
I am creating a shortcode in a wordpress theme which needs to show properties on area based it was working fine. I have tried to keep 10 area title which was custom one. For that i called varable as $area_title1 to 10 in the wordpress loop also i have added a counter and called the counter with the variable for getting $area_title1 i called variable as $area_title.$counter which was without counting it shows exactly the value for example 1 , 2, etc my code is below.
function home_category_with_image_session($atts){
ob_start();
$atts = shortcode_atts(
array(
'propertytype' => '',
'area' => '',
'area1' => '',
'area2' => '',
'area3' => '',
'area4' => '',
'area5' => '',
'area6' => '',
'area7' => '',
'area8' => '',
'area9' => '',
'area_title' => '',
'area1_title' => '',
'area2_title' => '',
'area3_title' => '',
'area4_title' => '',
'area5_title' => '',
'area6_title' => '',
'area7_title' => '',
'area8_title' => '',
'area9_title' => '',
),
$atts,
'home_category_type'
);
$area=$atts['area'];
$area1=$atts['area1'];
$area2=$atts['area2'];
$area3=$atts['area3'];
$area4=$atts['area4'];
$area5=$atts['area5'];
$area6=$atts['area6'];
$area7=$atts['area7'];
$area8=$atts['area8'];
$area9=$atts['area9'];
$area_title=$atts['area_title'];
$area_title1=$atts['area1_title'];
$area_title2=$atts['area2_title'];
$area_title3=$atts['area3_title'];
$area_title4=$atts['area4_title'];
$area_title5=$atts['area5_title'];
$area_title6=$atts['area6_title'];
$area_title7=$atts['area7_title'];
$area_title8=$atts['area8_title'];
$area_title9=$atts['area9_title'];
$property_type=$atts['propertytype'];
$custom_terms = get_terms(array ('taxonomy' => 'property_city_taxonomy',
'orderby' => 'count',
'order' => 'ASC',
'name' => array ($area, $area1, $area2, $area3, $area4, $area5, $area6, $area7, $area8, $area9 ),
) );
$counter = -1;
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => $property_type,
'tax_query' => array(
array(
'taxonomy' => 'property_city_taxonomy',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts())
{
$counter++ ?>
<div class="col-md-3 col-sm-4 col-xs-6"><a href="<?php echo get_term_link($custom_term); ?>?property-type=<?php echo "$property_type"; ?>"><div class="top-locations"><div class="image-holder">
<?php $custom_term_id = $custom_term->term_id;
$custom_term_meta = get_term_meta( $custom_term_id, 'uploadimage_61032', true );
$num = $loop->post_count;
$area_title_display = $area_title.$counter;
?>
<img src="<?php echo $custom_term_meta; ?>" alt="<?php echo $term->name; ?>" class="img-responsive" />
<?php echo $area_title_display; ?>
<div class="home-banner-overlay"></div>
<div class="area-name"><?php echo $custom_term->name; ?></div>
</div><div class="city-text-container text-center"><?php echo $num; ?> Properties Listed</div></div></a></div>
<?php
} }
// Restore original post data.
wp_reset_postdata();
return ob_get_clean(); }
add_shortcode('home_category_type', 'home_category_with_image_session');
//Featured Post Home
function home_featured_posts($atts){
ob_start();
$atts = shortcode_atts(
array(
'no' => '',
'posttype' => '',
),
$atts,
'home-featured'
);
?>
<div class="session-featured-title">
<h5>Featured Property <?php echo $atts['posttype']; ?></h5>
<div class="related-control"><a class="btn prev"><i class="fa fa-arrow-left"></i></a><a class="btn next"><i class="fa fa-arrow-right"></i></a></div>
</div>
<div id="featured" class="owl-carousel owl-theme">
<?php
$args_1= array(
'post_type' => $atts['posttype'],
'posts_per_page' => $atts['no'],
'meta_query' => array(
array(
'key' => 'we_recommend_make-featured-property',
'value' => '1'
)
)
);
query_posts($args_1); if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="item"><a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?>">
<div class="featured-image">
<?php the_post_thumbnail('full', array('class' => 'img-responsive') ); ?></div>
<div class="featured-text-holder">
<div class="recent-post-title"><?php the_title(); ?></div>
<div class="featured-meta-detail">
<div class="py-list-price"><?php ro_price(); ?></div>
<div class="py-list-bed"><?php ro_bedroom(); ?></div>
<div class="py-list-bath"><?php ro_bathroom(); ?></div>
</div>
</div>
</a></div>
<?php endwhile; endif; wp_reset_query(); ?>
</div>
Here is your questions answer in php Refer This
And modified code of yours is below.
function home_category_with_image_session($atts){
ob_start();
$atts = shortcode_atts(
array(
'propertytype' => '',
'area' => '',
'area1' => '',
'area2' => '',
'area3' => '',
'area4' => '',
'area5' => '',
'area6' => '',
'area7' => '',
'area8' => '',
'area9' => '',
'area_title' => '',
'area1_title' => '',
'area2_title' => '',
'area3_title' => '',
'area4_title' => '',
'area5_title' => '',
'area6_title' => '',
'area7_title' => '',
'area8_title' => '',
'area9_title' => '',
),
$atts,
'home_category_type'
);
$area=$atts['area'];
$area1=$atts['area1'];
$area2=$atts['area2'];
$area3=$atts['area3'];
$area4=$atts['area4'];
$area5=$atts['area5'];
$area6=$atts['area6'];
$area7=$atts['area7'];
$area8=$atts['area8'];
$area9=$atts['area9'];
$area_title[0]=$atts['area_title'];
$area_title[1]=$atts['area1_title'];
$area_title[2]=$atts['area2_title'];
$area_title[3]=$atts['area3_title'];
$area_title[4]=$atts['area4_title'];
$area_title[5]=$atts['area5_title'];
$area_title[6]=$atts['area6_title'];
$area_title[7]=$atts['area7_title'];
$area_title[8]=$atts['area8_title'];
$area_title[9]=$atts['area9_title'];
$property_type=$atts['propertytype'];
$custom_terms = get_terms(array ('taxonomy' => 'property_city_taxonomy',
'orderby' => 'count',
'order' => 'ASC',
'name' => array ($area, $area1, $area2, $area3, $area4, $area5, $area6, $area7, $area8, $area9 ),
) );
$counter = -1;
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => $property_type,
'tax_query' => array(
array(
'taxonomy' => 'property_city_taxonomy',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts())
{
$counter++ ?>
<div class="col-md-3 col-sm-4 col-xs-6"><a href="<?php echo get_term_link($custom_term); ?>?property-type=<?php echo "$property_type"; ?>"><div class="top-locations"><div class="image-holder">
<?php $custom_term_id = $custom_term->term_id;
$custom_term_meta = get_term_meta( $custom_term_id, 'uploadimage_61032', true );
$num = $loop->post_count;
$area_title_display = '$area_title'.$counter;
echo $area_title[$counter];
?>
<img src="<?php echo $custom_term_meta; ?>" alt="<?php echo $term->name; ?>" class="img-responsive" />
<?php echo $area_title_display; ?>
<div class="home-banner-overlay"></div>
<div class="area-name"><?php echo $custom_term->name; ?></div>
</div><div class="city-text-container text-center"><?php echo $num; ?> Properties Listed</div></div></a></div>
<?php
}
}
// Restore original post data.
wp_reset_postdata();
return ob_get_clean(); }
add_shortcode('home_category_type', 'home_category_with_image_session');
//Featured Post Home
function home_featured_posts($atts){
ob_start();
$atts = shortcode_atts(
array(
'no' => '',
'posttype' => '',
),
$atts,
'home-featured'
);
?>
<div class="session-featured-title">
<h5>Featured Property <?php echo $atts['posttype']; ?></h5>
<div class="related-control"><a class="btn prev"><i class="fa fa-arrow-left"></i></a><a class="btn next"><i class="fa fa-arrow-right"></i></a></div>
</div>
<div id="featured" class="owl-carousel owl-theme">
<?php
$args_1= array(
'post_type' => $atts['posttype'],
'posts_per_page' => $atts['no'],
'meta_query' => array(
array(
'key' => 'we_recommend_make-featured-property',
'value' => '1'
)
)
);
query_posts($args_1); if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="item"><a href="<?php the_permalink(); ?> " title="<?php the_title_attribute(); ?>">
<div class="featured-image">
<?php the_post_thumbnail('full', array('class' => 'img-responsive') ); ?></div>
<div class="featured-text-holder">
<div class="recent-post-title"><?php the_title(); ?></div>
<div class="featured-meta-detail">
<div class="py-list-price"><?php ro_price(); ?></div>
<div class="py-list-bed"><?php ro_bedroom(); ?></div>
<div class="py-list-bath"><?php ro_bathroom(); ?></div>
</div>
</div>
</a></div>
<?php endwhile; endif; wp_reset_query(); ?>
</div>
I am sure this will works for you.
I've been through other posts on here and elsewhere and compared my code to working examples I've done previously, but I can't find what the issue is. I;m using the following query to grab a featured article and store its ID:
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'desc',
'post_status' => 'publish',
'cat' => 564,
);
$featured_latest = new WP_Query($args);
$fid = array();
if( $featured_latest->have_posts() ) : while( $featured_latest->have_posts() ) : $featured_latest->the_post(); ?>
<?php $fid[] = get_the_ID(); ?>
<div class="top-featured">
<?php if( has_post_thumbnail() ) { ?>
<?php $image = get_the_post_thumbnail_url(get_the_ID(),'large'); ?>
<?php } else { ?>
<?php $image = get_stylesheet_directory_uri() . '/assets/images/blog/no-article-image.jpg'; ?>
<?php } ?>
<a class="article-link lazy" href="<?php the_permalink(); ?>" data-src="<?php echo $image; ?>">
<div class="text">
<h2><?php the_title(); ?></h2>
<?php
$date = get_the_date();
$cdate = date( 'c', strtotime($date) );
?>
<time datetime="<?php echo $cdate; ?>"><?php echo $date; ?></time>
<div class="excerpt">
<?php echo get_excerpt(140); ?>
</div>
<span class="fake-link">Read article</span>
</div>
</a>
</div>
<?php endwhile; wp_reset_postdata(); endif; ?>
Then lower down the page I use this query:
<?php
if( !empty( $fid ) ){
$fid = $fid;
} else {
$fid = array();
}
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'orderby' => 'date',
'order' => 'desc',
'post_status' => 'publish',
'cat' => 399,
'post__not_in' => $fid,
);
$top_reviews = new WP_Query($args);
if( $top_reviews->have_posts() ) : ?>
<div class="top-articles top-reviews">
<h2>Top product reviews</h2>
<div class="row">
<?php while( $top_reviews->have_posts() ) : $top_reviews->the_post(); ?>
<div class="col-12 col-md-4">
<?php if( has_post_thumbnail() ) { ?>
<?php $image = get_the_post_thumbnail_url(get_the_ID(),'large'); ?>
<?php $imgid = get_post_thumbnail_id( get_the_ID() ); ?>
<?php $alt = get_post_meta( $imgid, '_wp_attachment_image_alt', true); ?>
<?php } else { ?>
<?php $image = get_stylesheet_directory_uri() . '/assets/images/blog/no-article-image.jpg'; ?>
<?php $alt = 'No article image'; ?>
<?php } ?>
<a class="article-link" href="<?php the_permalink(); ?>" data-src="<?php echo $image; ?>">
<img class="lazy" data-src="<?php echo $image; ?>" alt="<?php echo $alt; ?>">
<div class="text">
<h3><?php the_title(); ?></h3>
<?php
$date = get_the_date();
$cdate = date( 'c', strtotime($date) );
?>
<time datetime="<?php echo $cdate; ?>"><?php echo $date; ?></time>
<div class="excerpt">
<?php echo get_excerpt(140); ?>
</div>
<span class="fake-link">Read article</span>
</div>
</a>
</div><!-- col -->
<?php endwhile; wp_reset_postdata(); ?>
</div><!-- row -->
</div>
<?php endif; ?>
$fid prints as an array with one item inside, but the second query does not exclude the post of that ID. I'm sure there's something glaringly obvious that I'm missing, but I can't for the life of me find it!
May be some other plugin or theme features overrides the array? var_dump and try what are the query_vars in the WP_Query object. then you can identify it. Or simply deactivate all the plugins and activate it one by one. then you can identify surely!
if any plugin overrides it, they should use a hook to do it. so search and see the priority of the hook. and then just you override it with high priority hook. example below.
add_action('pre_get_posts', 'your_callback_function_name', 999)
function your_callback_function_name($query){
$overridden_array = $query->get('post__not_in', array());
$overridden_array[] = $your_f_id;
$query->set('post__not_in', $overridden_array);
}
Thats all. Just rename those functions and variables as your wish.
You need to pass array in this format array('162','3074')
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'desc',
'post_status' => 'publish',
'post__not_in' => array('162','3074')
);
$top_reviews = new WP_Query($args);
Its working fine for me.. you can try in same way.
post__not_in (array) - use post ids. Specify post NOT to retrieve. If this is used in the same query as post__in, it will be ignored.
Change post__not_in value into Array.
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'orderby' => 'date',
'order' => 'desc',
'post_status' => 'publish',
'cat' => 399,
'post__not_in' => array('YOUR_POST_ID1','YOUR_POST_ID2'),
);
For more help see this link : Click Here
When printing out the WP_Query resuls, I found that the following was happening:
WP_Query Object ( [query] => Array ( [post_type] => post [posts_per_page] => 3 [orderby] => date [order] => desc [post_status] => publish [cat] => 399 [post__not_in] => Array ( [0] => 8117 ) ) [query_vars] => Array ( [post_type] => post [posts_per_page] => 3 [orderby] => date [order] => DESC [post_status] => publish [cat] => 399 [post__not_in] => Array ( [0] => 7990 )
It was suggested to me by dineshkashera that the pre_get_posts() filter may have been the cause. As I was not using this myself, I troubleshooted for plugin conflicts by deactivating all those that were not regular ones I used. After reactivating them one at a time, I found that the culprit was the Woocommerce Point of Sale plugin. I have deactivated this plugin for now and will seek a solution from the developer.
I have this code for showing new product as hscroll in mobile theme
but I want to don't show a category product with 1230 id
I add think by adding some code like: $products->category-> != 1230 to first if
please guide
<?php
// new arrivals products
$new_args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'orderby' =>'date',
'order' => 'DESC'
);
$products = new WP_Query( $new_args );
?>
<?php if ( $products->have_posts() ) { ?>
<div class="title-intro content-block-title"><?php _e( 'New Arrivals', 'woomobify' ); ?></div>
<div class="product-hscroll swiper-container swiper-init" data-auto-height="true" data-free-mode="true" data-slides-per-view="auto">
<div class="swiper-wrapper">
<?php while ( $products->have_posts() ) : $products->the_post(); global $product; ?>
<div class="swiper-slide">
<div class="card">
<div class="card-content">
<a href="<?= get_the_permalink(); ?>">
<?php
if ( has_post_thumbnail($products->post->ID) ) {
echo get_the_post_thumbnail( $products->post->ID, 'shop_catalog' );
} else {
echo '<img src="'.wc_placeholder_img_src().'"/>';
} ?>
</a>
<div class="title"><?php the_title(); ?></div>
<div class="item-text product-price">
<span class="price"><?= wc_price( $product->get_price() ); ?></span>
</div> </div> </div>
<?php endwhile; ?>
I think the solution you are looking for is described at
https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/
or to make it more easy, use the next arguments to retrieve all products except if the product is in the category(id) 1230
$args = array(
'posts_per_page' => -1,
'orderby' =>'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => array('1230'),
'operator' => 'NOT IN')));
I have this piece of code which works but it's showing only 5 posts (with custom taxonomy) where should be 7. If I hit the tag url, it shows the 7 registries, so the problem it's in this code and its query. I already tried nopaging = true, posts_per_page = -1 numberposts = -1 and setting the last two to fixed numbers, like 7 or 999; but none of this options seem to do the trick.
Hope someone can help me. Thanks.
add_shortcode('gpp_prod', function( $atts, $content = null ){
ob_start();
$atts = shortcode_atts(
array(
'category' => '0'
), $atts);
extract($atts);
$args = array(
'post_type'=>'gpp_prod',
'orderby' => 'title',
'order' => 'ASC'
);
if($category > 0 ){
$args['tax_query'] = array(
array(
'posts_per_page' => -1,
'taxonomy' => 'cat_prod',
'field' => 'term_id',
'nopaging' => true,
'terms' => $category
)
);
}
?>
<?php $products = get_posts($args);
$termt = get_term($category, 'cat_prod');
<div class="prod-cats">
<h1><?php echo $termt->name;?></h1>
<?php if(count($products)>0) {
foreach ($products as $key => $value) { ?>
<div class="prod-group">
<div class="prod-title"><?php echo do_shortcode( $value->post_title); ?></div>
<div class="prod-low">
<div class="prod-image"><img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($value->ID)); ?>"/></div>
<div role="tabpanel" class="prod-info">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Desc</li>
<li role="presentation">Specs</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab-1-<?php echo $value->ID?>"><?php echo do_shortcode( $value->post_content); ?></div>
<div role="tabpanel" class="tab-pane" id="tab-2-<?php echo $value->ID?>"><?php $meta_value = get_post_meta( $value->ID, 'meta-text', false );
if( !empty( $meta_value ) ) {
echo $meta_value[0];
} else {
echo 'No specs available';
}
?>
</div>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
}
?>
</div>
<?php
wp_reset_postdata();
return ob_get_clean();
});
posts_per_page needs to go in your $args array, not in $args['tax_query']. Also nopaging is redundant when setting posts_per_page = -1. Try this:
$args = array(
'post_type'=>'gpp_prod',
'orderby' => 'title',
'order' => 'ASC'
'posts_per_page' => -1,
);
if($category > 0 ){
$args['tax_query'] = array(
array(
'taxonomy' => 'cat_prod',
'field' => 'term_id',
'terms' => $category
)
);
}