short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API: The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will … Read more

Shortcode with multiple variables

If you were to enable debugging and test the code (not sure why you are reluctant to do that), you would see that there are problems with the code. Your array elements need to be separated by commas and PHP variables begin with $. What you have won’t work as is. That kind of pure … Read more

Custom taxonomy in short code

Not sure if is this, but you can add taxonomies in query: new WP_Query(array(‘posts_per_page’ => $num, ‘post_status’ => ‘publish’,’taxonomy’ => $taxonomy)); You can filter by term with $taxonomy => $term: $taxonomy = ‘seasons’; $term = ‘spring’ /* $terms = array(‘summer’,’winter’) an array */ new WP_Query(array(‘posts_per_page’ => $num, ‘post_status’ => ‘publish’,$taxonomy => $term)); More on WP_Query … Read more

short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API: The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will … Read more

Create a short code that inserts js

Put the script into an external file, set the selector there and enqueue it from your shortcode: if(! function_exists (‘aisis_toc’) ) { function aisis_toc() { if ( ! is_singular() ) return; wp_enqueue_script( ‘jquery-toc’, plugins_url( ‘js/jquery-toc.js’, __FILE__ ), array ( ‘jquery’ ), NULL, TRUE); return; } }

shortcode change variable base on user

If this works for you in the template: $s=”[cfdb-table form=”Contact form 1″ show=”Submitted Login,your-email,your-message” search=”AndrewA”]”; echo do_shortcode($s); then you could try: global $current_user; get_currentuserinfo(); $s = sprintf(‘[cfdb-table form=”Contact form 1″ show=”Submitted Login,your-email,your-message” search=”%s”]’,$current_user->display_name); echo do_shortcode($s);

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