How to format shortcode’s HTML in external file

function wpse450_show_video( $atts ) { extract(shortcode_atts(array( ‘id’ => 0 ), $atts )); if( is_numeric($id) ) { $ngvideo_title = get_the_title($id); } ob_start(); include ‘path/to/file/video.php’; return ob_get_clean(); } add_shortcode( ‘ngvideo’, ‘wpse450_show_video’ ); You can use $id, $atts in our file as you would in your function. The code in your file will behave just like it would … Read more

getting values from a shortcode with an include

include changes the scope. You would need to declare $classslider global before defining it, and then use global $classslider; before using it. function bf_shortcode_slideshow($atts) { global $classslider; extract(shortcode_atts(array( … I think that will fix your problem. I don”t understand why you are using include at all though. There must be a better way to make … Read more

Adding short codes from a page’s content on header and hiding the same from page’s content

This might work for you, trying to hook early to the_content filter to strip the shortcode tag from it: add_filter(‘the_content’, ‘ad_filter_the_content’,1,1); function ad_filter_the_content($content) { // specify page id or array of page ids to include if (is_page(5)) { return str_replace(‘[orbit-slider category=”test”]’, ”, $content); } return $content; }

wp_specialchars and wp_specialchars_decode in a shortcode plugin

The Codex description of these two functions: wp_specialchars: Converts a number of special characters into their HTML entities. Specifically deals with: &, <, >, “, and ‘. wp_specialchars_decode: Converts a number of HTML entities into their special characters. According to http://codex.wordpress.org/Function_Reference/wp_specialchars This function is deprecated as of WordPress 2.8.0. Please use esc_html instead. You don’t … Read more

how to show database content in wordpress post

For the sake of the example, I’ll assume you to have copied the relevant Table to the WordPress DB, to have named it wp_my_xtra_table and it to contain 3 columns (id,num_val,str_val). function wpse106832_shortcode_demo( $atts ) { global $wpdb; extract( shortcode_atts( array( ‘id’ => 1 ), $atts ) ); $table_row = $wpdb->get_row( ‘SELECT * ‘ . … Read more

How extend shortcode default values for a plugin?

You can hijack the shortcode and use your own additional logic. Sample code, not tested: add_action( ‘after_setup_theme’, function() { // Replace the plugin shortcode handler with your own. add_shortcode( ‘standout-css3-button’, function( $atts, $content = NULL ) { // Let the plugin make the button and store the result. $button = scss3button( $atts, $content ); // … Read more

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