Are php template shortcodes ok?

Is it Ok? Yes! Is it Optimal? No What Would Be Better? Shortcodes map on to PHP functions, so why not cut out the middle man and go straight to the original function? Are there any other downsides? Yes! That shortcode had to come from somewhere, now you have a dependency, maybe the plugin that … Read more

WordPress transients for a shortcode

Use this instead of the line in wich you define $days (your second line): $transient = get_transient( ‘your_transient_key’ ); if( !$transient ): $days = file_get_contents( ‘json_file’ ); set_transient( ‘your_transient_key’, $days, DAY_IN_SECONDS*7 ); else: $days = $transient; endif; $days = json_decode( $days ); … May be a bit rough but you get the idea.

shortcode inside another shortcode

I usually apply the_content filters to $content to do this. I think you can aslo use do_shortcode($content); // Column ShortCode Description function column_scdescription($atts, $content=”null”) { return ‘<div class=”description”>’ .apply_filters(‘the_content’, $content) . ‘</div> <!– description ends here –>’; } add_shortcode (“product-description”, “column_scdescription”); Read up on Nested Shortcodes in the codex.

Stray closing paragraph tag when using shortcodes

This is frustrating issue as I can’t depend on the content editors to be savvy enough with WordPress / HTML to understand how the text they input will be parsed… –EDIT– Having thought of this a bit more I have reconsidered my earlier answer. HTML5+ comes with the Tidy extension, if you are able to … Read more

How to display the names of users from a specific group with a shortcode?

Below is my own answer to the question. I will appreciate any constructive comment. add_shortcode( ‘group_members’, ‘group_members_shortcode_handler’ ); function group_members_shortcode_handler ( $atts, $content = null ) { global $wpdb; $querystr = “SELECT * FROM wp_groups_user_group”; $users = $wpdb->get_results($querystr, OBJECT); $output=””; foreach ($users as $user) { if($user->group_id == $atts[‘group_id’]){ $firstName = esc_html(get_user_meta($user->user_id, ‘first_name’, true)); $lastName = … Read more

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