Recent post display using shortcode

You have missed the quotes in the_permalink(). Use following code 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() ) { $list .= ‘<a class=”single-image link-icon” href=”‘. get_permalink().'”>’.the_post_thumbnail(array(300,200),array(‘alt’ =>$title)).'</a>’; } $list .= ‘<h6 class=”title”><a href=”.the_permalink().”><span>”‘.the_title().'”</span></a></h6>’; echo ‘<div class=”entry-body”>’; … Read more

Inserting PHP inside do_shortcode

This is the code I would use: $open_shortcode=”[vc_accordion]”; $shortcode_data=””; $close_shortcode=”[/vc_accordion]”; $myarray = array( ‘tabs’ => array( ‘title’ => ‘Section 1’, ‘content’ => ‘Any text here’ ), array( ‘title’ => ‘Section 2’, ‘content’ => ‘Any text here’ ) ); foreach( $myarray[‘tabs’] as $tab ){ $shortcode_data .= ‘[vc_accordion_tab title=”‘ . $tab[‘title’] . ‘”]’ . $tab[‘content’] . ‘[/vc_accordion_tab]’; … Read more

creating shortcode to pull json array

As per documentation on wp_remote_get() it doesn’t return you just the body of requested resource. Its return will be either the array of data or WP_Error object on failure. The simplest snippet to get to the body would be: $json = wp_remote_retrieve_body( wp_remote_get( $url ) ); PS it’s kinda weird to be doing this in … Read more

Using API to generate short link

You never need do_shortcode(), better said, almost never, there are a few cases where do_shortcode() could be appropiate. Note how you could do just: echo shorten_url( ‘http://mylink.com ‘ ); instead of: echo do_shortcode(‘[shorten]http://mylink.com[/shorten]’); Think about shortcodes as PHP functions placeholders; they are intended to be use where you can not execute PHP directly, like the … Read more

WP theme with Backbone

Well if you use Backbone with _s (https://github.com/tlovett1/_s_backbone) you will not be in problem. They used backbone for some effects and enqueuing is present still. /** * Enqueue scripts and styles. */ function _s_backbone_scripts() { wp_enqueue_style( ‘_s_backbone-style’, get_stylesheet_uri() ); wp_enqueue_script( ‘_s_backbone-navigation’, get_template_directory_uri() . ‘/js/navigation.js’, array(), ‘20120206’, true ); wp_enqueue_script( ‘_s_backbone-skip-link-focus-fix’, get_template_directory_uri() . ‘/js/skip-link-focus-fix.js’, array(), ‘20130115’, … Read more

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