Shortcode always displaying at the top of the page

You can buffer the output like this: ob_start(); include(locate_template(‘loop-‘.$module.’.php’)); return ob_get_clean(); EDIT. I tried this, worked fine. function friendly_loop_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( ‘category’ => ”, ‘module’ => ” ), $atts ) ); ob_start(); include(locate_template(‘loop-‘.$module.’.php’)); $output = ob_get_clean(); //print $output; // debug return $output; } if (!is_admin()) { add_shortcode(‘test’, ‘friendly_loop_shortcode’ … Read more

How to use other shortcodes inside Contact form 7- forms? [closed]

There’s two ways to do what you’re wanting. First way is to add this code to functions.php of the Contact Form 7 plugin: add_filter( ‘wpcf7_form_elements’, ‘mycustom_wpcf7_form_elements’ ); function mycustom_wpcf7_form_elements( $form ) { $form = do_shortcode( $form ); return $form; } That allows you to drop shortcodes directly into CF7. Second is to add the Accordion … Read more

Pass boolean value in shortcode

Is easy to use 0 and 1 values and then typecasting inside the function: [shortcode boolean_attribute=”1″] or [shortcode boolean_attribute=”0″] but if you want you can also strictly check for ‘false’ and assign it to boolean, in this way you can also use: [shortcode boolean_attribute=”false”] or [shortcode boolean_attribute=”true”] Then: add_shortcode( ‘shortcode’, ‘shortcode_cb’ ); function shortcode_cb( $atts … Read more

How do I escape a ‘]’ in a short code?

I don’t know of an official escape syntax for shortcodes and there likely isn’t one. When wordpress parses for shortcodes it looks for [ and ]. If you want to use square brackets within a shortcode, using the respective html ASCII entities escapes them. I.e. replacing [ by [ and ] by ]. WordPress will … Read more

Split Content and Gallery

Open to anybody who can simplify this but here’s what I came up with that worked for me. First thing’s first – get the gallery, using get_post_gallery(), as soon as the loop starts: <?php if( have_posts() ) : ?> <?php while( have_posts() ) : the_post(); $gallery = get_post_gallery(); $content = strip_shortcode_gallery( get_the_content() ); ?> <div … Read more

What does extract( shortcode_atts( array( do?

shortcode_atts() works like array_merge(): It merges the second list of arguments into the first one. The difference is: It merges only keys present in the first argument ($default). extract() then takes the array keys, sets these as variable names and their values as variable values. ‘w’ => ‘500’ in your example becomes $w = ‘500’. … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş