Rewriting WordPress Gallery Shortcode with Bootstrap Carousel

In a recently personal theme project for publishing travel posts, I desired a slider-style image gallery rather than the standard column/list-style one WordPress uses out of the box. I like the look-and-feel of the Bootstrap Carousel, so my challenge was this: Is it possible to mash up the WordPress Gallery Shortcode with Bootstrap’s Carousel? I’ve … Read more

Recent post display using shortcode

I am trying to display recent post in static page home-content.php. I’ve added this code in function.php function my_recent_posts_shortcode($atts){ $q = new WP_Query( array( ‘orderby’ => ‘date’, ‘posts_per_page’ => ‘4’) ); $list =””; while($q->have_posts()) : $q->the_post(); echo ‘<div class=”item”>’; $title=get_the_title(); if ( has_post_thumbnail() ) { echo ‘<a class=”single-image link-icon” href=”‘ . get_permalink() . ‘”>’; $list … Read more

Inserting PHP inside do_shortcode

I am trying to use an existing shortcode for an accordion element in a custom template for my wordpress site. Basically, I need to insert PHP arrays inside this shortcode, like so: <php do_shortcode(‘[vc_accordion]’;> PHP arrays here <php do_shortcode(‘[/vc_accordion]’;> Does anyone know if a solution? 3 Answers 3 This is the code I would use: … Read more

Is it possible to delay execution of shortcode output callback?

I have a problem : shortcode output callback triggered too early. /* Defined in plugin constructor */ add_shortcode( ‘foobar’ , array($this,’pre_render_routine’)); function pre_render_routine () {/* Do something*/} Before shortcode will be displayed , must be requested information about metafields which displayed in current main loop : add_action( ‘loop_end’, array($this,’retrieve_metadata’) ); function retrieve_metadata( WP_Query $wp_query ) … Read more

Using API to generate short link

I want to use a shortcode that generates a short URL from API of Premium URL Shortener script. I added code from API to my template functions: // Main Function function shorten_url($url){ $siteurl=”http://go.mysite.com”; // FOR Example http://gempixel.com/short $apikey=”8jkyA3e7xs1J”; // You can get it from the user account if($apikey && $siteurl){ $short=@file_get_contents(“$siteurl/api?api=$apikey&url=”.strip_tags(trim($url))); $short=json_decode($short,TRUE); if(!$short[“error”]){ return $short[“short”]; … Read more