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

Displaying a random user with a shortcode

By default WordPress allow only order ASC and DESC. However, you can use WP_User_Query and the action pre_user_query to adjust the query (that is passed by reference) just like you want. This is efficient because you get only one user, not all. function my_user_by_rand( $ua ) { // remove the action to run only once … Read more

Plugin form unable to process

You missed name attribute of <input type=”submit” value=”<?php _e(‘Submit’); ?>”/> HTML tag. i.e. It should be looks like: <input type=”submit” name=”Submit” value=”<?php _e(‘Submit’); ?>”/> Else, You have to change if condition inside function form_processing() OLD: if(isset($_POST[‘Submit’])){ Replace with: if(isset($_POST[‘rollNumber’])){ Hope this will helps you.

filter title from shortcode

why not to use the_title filter? add_filter(‘the_title’, ‘the_title_filter’); function the_title_filter($title){ $post = get_post(get_the_id()); //enter code here return $title; } as for shortcode – its imposible. in logical way – imposible.

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