Thread Starter
jhoell
(@jhoell)
Here is my shortcode:
<?php
$category = get_category( get_query_var( 'cat' ) );
$cat_slug = $category->slug;
echo do_shortcode('[ajax_load_more category="'.$cat_slug.'" meta_key="_is_ns_featured_post" meta_value="" meta_compare="NOT EXISTS" pause="true"]');
?>
Hi jhoell,
I’m not really sure – all ALM does is pass the ‘NOT EXISTS’ to the meta_query so if it’s not working its possible there is another issue.
Is there any chance you can confirm this work with a standard query?
I am having this issue as well
The standard query returns posts
$nargs = array(
‘posts_per_page’ => -1,
‘post_type’ => ‘post’,
‘meta_query’ => array(
array(
‘key’ => ‘_vid’,
‘compare’ => ‘NOT EXISTS’
)
)
);
$pageposts = get_posts( $nargs );
but the following shortcode doesn’t:
echo do_shortcode(‘[ajax_load_more posts_per_page=”4″ meta_key=”_vid” meta_compare=”NOT EXISTS” button_label=”MORE” ]’);
The _vid field is an “Upload” type field…
Might be an issue with the empty meta_value. I will take a look later today or tomorrow.
If I give it a value it doesn’t work either…
I think there a few issues are happening here and all are related to the custom meta_query in the Ajax Load More plugin.
I’m going to do some debugging to try to sort this out – most of the issues are surrounding empty meta_values.
Ok, I was incorrect above.
The issue is the meta_key value parameter.
If the plugin locates a meta_key value it adds the query argument meta_key => $meta_key to the query – which is an issue
meta_key is generally used for ordering so to fix this I will check against the orderby value before adding the meta_key to the query.
This will be packaged up in the next release – likely not for a few weeks.
In the meantime, if you want to add the fix yourself…
Line 1156 of /ajax-load-more/ajax-load-more.php
replace
// Meta_key, used for ordering by meta value
if(!empty($meta_key)){
$meta_key_single = explode(":", $meta_key);
$args['meta_key'] = $meta_key_single[0];
}
with:
// Meta_key, used for ordering by meta value
if(!empty($meta_key)){
if (strpos($orderby, 'meta_value') !== false) { // Only order by meta_key, if $orderby is set to meta_value{_num}
$meta_key_single = explode(":", $meta_key);
$args['meta_key'] = $meta_key_single[0];
}
}
Let me know if this works.
Thank you so much for your speedy reply
I tried it on a page that has several instances of the shortcode.
The first two didn’t work but the others did….
I tried it on a page that has several instances of the shortcode.
hmm… Well I’ll be releasing a new version either tomorrow or Monday… So when you update the plugin see if it works on all. I’ve made some changes in addition to what I have above.
Cheers,
Sorry for not updating earlier – Works beautifully now and really enhances the website.
Thank you so much!
Excellent. Thanks for posting back here.
Closing/