Change post type depending on shortcode

the callback function has 3 parameters and the 3rd is the tag name : add_shortcode( ‘all_faq’, ‘commonFunction’ ); add_shortcode( ‘wordpress_faq’, ‘commonFunction’ ); function commonFunction($attr, $content, $tag) { $cores = [ “all_faq” => “Faq”, “wordpress_faq” => “wp-Faq”, ]; $args = array( ‘post_type’ => $cores[$tag], ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘-1’ ); // … }

Basic custom Shortcode not working

get_the_content returns the content as is without processing, it does not pass it through the filters that are used in the_content such as oembeds or shortcodes. This filter is also called the_content ( coincidence ) Instead use this: $email_body = apply_filters( ‘the_content’, get_the_content() );

caption shortcode using image alt as caption

To remove caption text, you can override the caption short-code using below code: add_filter( ‘img_caption_shortcode’, ‘my_img_caption_shortcode’, 10, 3 ); function my_img_caption_shortcode( $empty, $attr, $content ){ $attr = shortcode_atts( array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ => ” ), $attr ); if ( 1 > (int) $attr[‘width’] || empty( $attr[‘caption’] ) ) … Read more

Change shortcode value by jquery in WP Editor

Shortcodes are backend stuff, so you can’t just change values of shortcodes itself in editor with jQuery, the thing you can do is to call both shortcodes, hide one of them, and on click show him and hide other one. It all depends what do you want to do, but one of the option is … Read more

Calling PHP Titles inside Javascript Markup

First, don’t echo your php, but assemble everything in a string, let’s say $titlestring. Next, make this string available for access by the javascript (the slug is the one you used to register the script): $params = array ( ‘titlestring’ => $titlestring, ); wp_localize_script (‘your-script-slug’, ‘IframeTitle’, $params); Finally, access the variable in the script: ‘<div … Read more