Autogenerate shortcodes from an array of strings

Your shortcode name (‘$name’ ) is invalid. If you want to use the variable, it should be add_shorcode( $name, …. Also, the function name is invalid. Since you want to make it “dynamic” (I’m assuming you want it to be {$name}_sc, then maybe you should use an anonymous function. What you have is somewhat unconventional … Read more

Register visits of my pages in wordpresss

It’s not a good idea to store user’s data on a file that is publicly accessible. A better way would be to create a folder, and store your file under it. Also, it’s better to use WordPress’s filesytem class rather than directly using PHP’s built-in functions. Here’s a quick fix: function wpse381320_after_login( $atts ) { … Read more

ShortCode and extra

I discover that it’s a know bug, and will be fix in future release Reference here So then, i used this code… not pretty, but do the magic !, thanks $content = do_shortcode( shortcode_unautop( $content ) ); if ( ‘</p>’ == substr( $content, 0, 4 ) and ‘<p>’ == substr( $content, strlen( $content ) – … Read more

WordPress Shortcode wrap around div

If by template file you mean a php file in the themes folder, you can call do_shortcode to have the shortcode processor do its magic on your div. EDIT: not entirely sure I understand what you want, but you could try this: <div id=”subscription”> <?php do_shortcode(‘[subscribe]’.call_php_function().'[/subscribe]’);?> </div>

Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?

I don’t know in what exact order filters are applied to the_content(); and whether that’s early enough, but if it doesn’t work for you, I believe it is safe to assume that you’re right in thinking that the shortcode is applied to late. From /wp-includes/shortcodes.php (line 296, wp 3.2.1) it can be seen that shortcodes … Read more

Is it possible to create a shortcode that will query a post based on taxonomies?

here is a simple shortcode that can handle taxonomies, post types and any other parameter that WP_Query takes: add_shortcode(‘posts’,’posts_shortcode_handler’); function posts_shortcode_handler($atts, $content){ extract(shortcode_atts(array( ‘posts_per_page’ => ‘5’, ), $atts)); global $post; $temp = $post; $posts = new WP_Query($atts); $retVal=””; if ($posts->have_posts()){ while ($posts->have_posts()){ $posts->the_post(); // these arguments will be available from inside $content $parameters = array( … Read more

How to handle shortcodes when using the JSON API

You can add your own AJAX API for do_shortcode. Add this to a suitable location (i.e. functions.php or a plugin): add_action(‘wp_ajax_doshortcode’, ‘ajax_doshortcode’); function doshortcode() { echo do_shortcode($_POST[‘text’]); die(); // this is required to return a proper result } And this to your Javascript: $.ajax({ url : ajaxurl, data : { action : ‘doshortcode’, text : … Read more

Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?

Basically the img_caption_shortcode filter allows you to completely replace the default image caption. If you want to do that, you’ll need to ask WP to pass all the argument of the filter to your callback function. <?php add_filter(‘img_caption_shortcode’, ‘wpse81532_caption’, 10, 3 /* three args */); Then your callback will need to take care of all … Read more

Allow shortcode in the author bio textarea

It a matter of using do_shortcode in your author.php template file (or wherever applies). This function has to be “echoed”. And instead of using the_author_meta (which echo‘s the result), use get_the_author_meta. <?php echo do_shortcode( get_the_author_meta( ‘description’ ) ); ?>

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