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

Adding Image Count to Multigallery

You can try function multi_gallery_shortcode($atts, $content=null) { extract( shortcode_atts( array( ‘pid’ => 0, ), $atts ) ); //format input $pid = intval($pid); // construct a post object dependent on the input value if($pid>0){ // query a post object $pobj = get_post( $pid ); }else{ global $post; // current post object $pobj = &$post; } // … Read more

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