$wpdb returns duplicate posts

Nevermind, I solved it on my own. While reading on the WordPress Codex for $wpdb, I saw that if I use OBJECT_K it will remove the duplicates and that solved my problem. If it helps anyone, here is my working code: function latest_posts_after_last_login( $atts ) { global $wpdb, $current_user; $atts = shortcode_atts( array( ‘post_type’ => … Read more

Visual Composer creating own shortcodes with vc_map() to return simple Image

Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image sizes. You can use it like this: $imageSrc = wp_get_attachment_image_src($image_url, ‘thumbnail’); if( $imageSrc ) { echo ‘<img src=”‘ . $imageSrc[0] . ‘” />’; } The thumbnail param could be replaced by medium or another valid image size. The … Read more

Insert shortcode between ”

just use <?php echo do_shortcode(‘[YOUR_SHORT_CODE_HERE]’);?> For more information: Short-code in code file $cb_byline=”<div class=”cb-byline”>” . $cb_author . $cb_date . $cb_cat_output . $cb_comments . $cb_post_views . do_shortcode(‘[YOUR_SHORT_CODE_HERE]’). ‘</div>’; } For Plugin “I Recommend This” : <?php if( function_exists(‘dot_irecommendthis’) ) dot_irecommendthis(); ?>

How do I pass custom shortcode-extracted variables (taxonomy) into a query function for WordPress RoyalSlider?

Two words – variable scope. Use a closure instead and pass $rstax through with use: add_filter( ‘new_royalslider_posts_slider_query_args’, function ( $args ) use ( $rstax ) { return array( ‘post_type’ => ‘carousel-slide’, ‘orderby’ => array( ‘menu_order’ => ‘ASC’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘carousel-slide-category’, ‘field’ => ‘slug’, ‘terms’ => $rstax, ), ), ) } … Read more

Shortcode not working in widget

You have a conditional in your function that will skip (return) if the current “view” is not a single post. You also have an undefined variable $content – the following has the condition removed and undefined variable fixed (always, always have debugging on when building with WordPress): function newsletter_signup_shortcode( $atts ) { $post_type = get_post_type(); … Read more