I have a custom shortcode with label [form-edit] inside this function i need execute one plugin short e.g [Form id="10"]. The given below is my non working code.
add_shortcode('form-edit', 'form_edit_function');
function form_edit_function(){
$fid = $_GET['fid'];
echo do_shortcode('[Form id="'.$fid.'"]');
}
How to make it possible? please Help
I think the issue is the use of $_GET within a function as that might not be available when calling the_content or whatever function you are adding.
function form_edit_function( $atts , $content = null ) {
// Extra attributes into variables
extract( shortcode_atts(
array(
'fid' => '' // the default value if not passed
), $atts )
);
$html = do_shortcode('[Form id="' . $fid . '"]');
// store in variable and return other echo will not
// put it in the correct place within your content
return $html;
}
// Use in post content or other places as [form-edit fid="1][/form-edit]
add_shortcode( 'form-edit', 'form_edit_function' );
Usually, a shortcode sends it's output via a RETURN statement, not an ECHO. If you echo it, it will be sent outside the normal action order of the Wordpress request. It will just be shoved into the header of your output, maybe not even visible. Also, you understand you have two shortcodes here, "form-edit" and "Form", right? Both are insanely bad names for a shortcode. Shortcode names are case sensitive. Are you sure your second shortocde is "Form" and not "form"?