Tell us what you are trying to do?
I have created a count of products.
/**
*Count posts of products
*/
function u_post_count() {
$user_post_count = count( get_posts( array(
'post_type' => 'product',
'author' => get_current_user_id(),
) ) );
return $user_post_count;
}
I have tried to use it in a conditional but it doesn't seem to work
[wpv-conditional if=" ( u_post_count() gt '1') " debug="true"]True if greater than 1 product[/wpv-conditional]
Is there anything obvious I am doing wrong?
Hi, if nothing appears in the debug information it indicates a syntax error or an unregistered function call. Did you register the custom function u_post_count in Toolset > Settings > Front-end Content > Functions inside conditional evaluations?
Hi Christian,
yes, I registered the function - still can't get it to work. Would there be a different call for products? I also created a loop just for products and used the wpv-items-count but that returned all child posts ids.
Are you testing as a logged-in User, or as a guest User? I think this function will give false positives if you test with guest Users. Otherwise it seems to be working fine for me so there must be something else going on. I'll be glad to take a look if you provide login credentials and show me where to find this conditional on the front end of the site.