What is the $atts parameter in shortcode_atts()?

When a user writes a shortcode: [my_shortcode att1=”Attribute 1 value” att2=”Attribute 2 value”] The attributes are passed to the shortcode’s callback function as an array as the first argument: function my_shortcode_callback( $atts ) { // $atts = array( // ‘att1’ => ‘Attribute 1 value’, // ‘att2’ => ‘Attribute 2 value’, // ); } add_shortcode( ‘my_shortcode’, … Read more

Post loop created via shortcode not displaying shortcode in content

get_the_content() does not have the the_content filters applied to it, which is where do_shortcode() is hooked in. Those filters are only applied in the_content(). Those two functions are not simply get/echo versions of each other. get_the_content() is lower level. This is an anomaly in the API, and is that way for historical reasons. For instance, … Read more

How to call custom taxonomy categories with shortcodes

Take a look at category post shortcode to get an idea and here is the plugin with minor modifications to call your post type and taxonomy: // Taxonomy category shortcode function cat_func($atts) { extract(shortcode_atts(array( ‘class_name’ => ‘cat-post’, ‘totalposts’ => ‘-1’, ‘category’ => ”, ‘thumbnail’ => ‘false’, ‘excerpt’ => ‘true’, ‘orderby’ => ‘post_date’ ), $atts)); $output=”<div … Read more

nested Shortcode doesn’t work

From the page you linked: The shortcode parser correctly deals with nested shortcode macros, provided their handler functions support it by recursively calling do_shortcode(): You need to recursively call do_shortcode() on any shortcode handler that could contain nested shortcodes. So for example: function wpse18659_permalink( $atts, $content ){ return ‘<a href=”‘ . get_permalink() . ‘” title=”Permalink … Read more

How do I hardcode a WordPress shortcode into my theme?

Check out do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode do_shortcode(‘[shortcode option1=”value1″ option2=”value2″]’); So your example would be: do_shortcode(‘[post_comments]’); What might be easier is to tap into the underlying comment functions: http://codex.wordpress.org/Function_Reference/comments_number <p> This post currently has <?php comments_number( ‘no responses’, ‘one response’, ‘% responses’ ); ?>. </p> You can also use get_comments_number which returns the value rather than printing it … Read more

get attributes/part of the gallery shortcode

The task It’s not as easy, as it looks at a first glance. The main problem is, that you can define your own shortcode and simply override the default. Actually that’s what some themes are doing (blame you ThemeForest authors!). In this case, simply hooking into post_gallery won’t work in every case. Drawbacks for post_gallery … Read more

Using shortcodes to parse POST request (containing the data from a front-end form)

Alway send submissions to the page the form is displayed. In your shortcode callback you can then display proper error or success messages. Sample: add_shortcode( ‘classifiedsform’, ‘classifiedsform_callback’ ); function classifiedsform_callback() { if ( ‘POST’ !== $_SERVER[‘REQUEST_METHOD’] or ! isset ( $_POST[‘classifieds’] ) ) { return classifieds_input_form(); } // process input show errors or success message … Read more

I dont want to show shortcode in tag

A) If you want to show the shortcode syntax you can try to write it with double brackets in the editor: <pre>[[shortcode foo=”bar”]]</pre> It will then display as <pre>[shortcode foo=”bar”]</pre> on your frontend and it will not activate the shortcode callback. B) Or if you want some extra formatting, you could define your own pretty … Read more

Shortcode output is screwed up when arrow symbol “

This issue was introduced in WP 4.2.3 with the introduction of the do_shortcodes_in_html_tags() function, which does a HTML parse of content to protect against content containing shortcodes authored by untrustworthy contributors/authors who by specially crafting shortcode attributes can create XSS exploits. If that security situation doesn’t apply to you and you only want this to … Read more

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