Shortcodes not working in an AJAX call

I believe the problem is you are not calling do_shortcode() in the output buffer. You don’t need to be running the loop within the output buffer since I can assume get_content_template() simply returns HTML with embedded shortcodes. Save that to a string variable, then run that through the do_shortcode() and save the echoed output to … Read more

has_shortcode for content added after the content

For this, you’ll actually want to utilize the wp_enqueue_scripts action instead of wp_head. wp_enqueue_scripts is technically the proper way to add scripts and styles to your site. This action allows us to both register scripts and styles for later use (which is what we want here) and allows us to output scripts and styles to … Read more

How I make a shortcode for this code?

You should read the Shortcode API as suggested. This should give you an overview of what is happening and how shortcodes should be used. One important thing to remember here, shortcode content should be returned, not echo’ed. Here is also a tutorial that help me a lot. Just a quick tip here, shortcodes should always … Read more

manipulate a plugins shortcode

you could remove_shortcode( ‘nggallery’ ); and then add it again: function put_script_after_nggallery_shortcode( $atts ){ global $nggShortcodes; $nggShortcodes->show_gallery($atts); //or otherwise duplicate the callback function wp_enqueue_script(‘special-ngg-sciprt’, ‘url-to-script’, null, null, true); } add_shortcode( ‘nggallery’, ‘put_script_after_nggallery_shortcode’ ); i’m not sure my show_gallery will work, but seems logical what script do you need to add? why not just wp_enqueue_script on … Read more

Prevent add_shortcode from escaping a tag

Look at the source of the_content(): function the_content($more_link_text = null, $stripteaser = false) { $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; } As you can see, there is no filter to prevent that. If you really need inline JavaScript in an XML document you have to escape … Read more

Do not show child pages of child pages

You can do that with using the depth argument. I also created an array of your arguments for better readability. The depth argument accepts the following parameters: ‘depth’ (int) Number of levels in the hierarchy of pages to include in the generated list. Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and … Read more

Get Shortcode Attributes

I figured it out. With the shortcode set as [camp_posts type=”academic, sports”] the code that does the trick is this: function camp_posts_function($atts) {//Creates shortcode [camp_posts type=”academics, sports”] $atts=shortcode_atts( array( ‘type’ => ‘nothing’, ), $atts, ‘camp_posts’); $ShortcodeAtts=esc_attr($atts[‘type’]);//Puts “type” attribute into a variable $ShortcodeAttsArray = explode(‘,’, $ShortcodeAtts); $IDout = array();//Initializes array foreach($ShortcodeAttsArray as $slug) { array_push($IDout, get_category_by_slug($slug)->term_id);//Gets … Read more

Some doubts about gallery shortcode in WordPress

If you want to display the attached image gallery, from another post, you can use: where the custom id attribute is the post ID. If you want limit the number of items in a gallery, there seems to be a plugin available on wordpress.org called Limit parameter for gallery shortcode (no affiliation). It uses the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)