Skip Navigation

[Resolved] Trying to find result of shortcode

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by AlimB3245 4 years, 3 months ago.

Author
Posts
#1808509
Screen Shot 2020-10-12 at 5.57.54 PM.png

Tell us what you are trying to do?

It's the first time I've created a shortcode.. actuallY I just tweaked an existing one created by Toolset supporter Waqar to suit my use.. here it is

add_shortcode('eyewear-collection-exists','check_eyewear_collection');
function check_eyewear_collection() {
    $content = do_shortcode("[wpv-view name='related-optician-eyewear-collection-eyewear-collection-ids']");
 
    if(!empty(trim($content))) {
        return '1';
    }
    else
    {
        return '0';
    }
}

I've registered the shortcode as required in the "Third-party shortcode arguments" section, at WP Admin -> Toolset -> Settings -> Front-end Content.

I created a conditional block and I got this option to first select the criteria so I selected Custom Shortcode and the short code was listed .. so all good..

then it asked for some short-code attribute.. not sure what I needed to put here so I left it blank.. then I used '=' and on the right hand side selected 'Static Value' and put '1'

I expected this to work but I am not able to see the result when there is an Eyewear Collection that exists.. I ran the view using custom html
[wpv-view name='related-optician-eyewear-collection-eyewear-collection-ids']

and I am able to view the collection id.. here..
hidden link

Just below the stars you will see the 2 ids.. one of them is the eyewear collection id.. so if it exists why is my conditional output showing as blank?

I've created a condition output where it's like this..
https://toolset.com/wp-content/uploads/tmp/Screen_Shot_2020_10_12_at_5.57.54_PM.png

but it doesn't seem to work.. what am I doing wrong?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

#1808541

My issue is resolved now. Thank you!

It was my mistake... I didn't realise I needed to activate the Code in settings..;-)..

Regards,
Alim