0

What I'm basically trying to do is check if a shortcode is returning any content, I'm using a plugin called Ninja forms and they have default content posting using their own shortcodes which look like this:

[ninja_forms_field id=84]

Assuming it works like a WordPress's default shortcode, how would I check if it returns any content, I've been trying to get this basic PHP code to work but it doesn't seem to ever evaluate as true:

<?php
if(!empty([ninja_forms_field id=84])){
    echo "has content";
} else{
    echo "not working";
}

I'm using a WP plugin called "Insert PHP" to run PHP in the default post form, I did several test and this plugin runs PHP wonderfully, so it's the shortcode logic that's failing me.

Here's a quick Ninja Forms article on their Shortcodes, this might help

3

Run the Shortcode through do_shortcode and check what the output contains.

$shortcode_content = do_shortcode( '[ninja_forms_field id=84]' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.