[Resolved] correct syntax for shortcode within shortcode
This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is that the customer had a custom shortcode that he was passing to views as a shortcode parameter but the shortcode doesn't filter the view.
Solution:
In order for custom shortcodes to work here they would need to be added to our views 3rd party shortcode arguments.
This can be found in Toolset->Settings->Frontend and you just need to add the name of the shortcode and it should start working.
This support ticket is created 6 years 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.
I am trying to: pass an argument to a view via a shortcode
Link to a page where the issue can be seen: n/a
I expected to see: see the attached screen shots
Instead, I got: see the attached screen shots
There are 3 lines in the test page. The first calls a shortcode and returns the correct value. The second calls the shortcode with a hard-coded value and the view properly displays. The third line attempts to call the view using the embedded shortcode and the output is incorrect. Here is the source code for the shortcode:
//***************************************************************
// return current supervisor based on current user
//***************************************************************
function sbf_return_current_supervisor() {
$user_id = get_current_user_id();
$key = 'wpcf-supervisor-details-post-id';
$single = true;
$result = get_user_meta( $user_id, $key, $single );
if($result) {return $result;} else {return -9999;}
} // sbf_return_current_supervisor
add_shortcode( 'sbf_return_current_supervisor', 'sbf_return_current_supervisor' );
I have enclosed screen shots of the view definition.
Thanks for any help. If there is a better way to accomplish this, please feel free to suggest. This type routine/fi;ter will be used in many views throughout the application. There are many CPT's and a supervisor should only be able to see and/or edit records that are assigned to him/her.
Addendum to previous post: I took a look at the source and the incorrect output looks like part of an error message that says "View not found". Hope this helps.
I dont think the issue here is necessary the quotes. Did you add the shortcode name "sbf_return_current_supervisor" to the views 3rd party shortcode arguments ?
If not could you try doing this and let me know if it starts working.