Wp_localize_script from Shortcode [closed]
Wp_localize_script from Shortcode [closed]
Wp_localize_script from Shortcode [closed]
On a separate thread, I found out that it was indeed possible to customize the output of the Gallery Shortcode using some code in the functions.php. The code below would be a fairly standard version of the slider without captions. You’d obviously need to make sure you include Jquery and Bootstrap files as you would … Read more
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
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
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
Is it possible to delay execution of shortcode output callback?
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
Okay, I think I’ve figured out what you’re actually asking. You’re asking what the variable for the bit between the shortcodes. If that is all you are asking, then the answer is the parameter variable $content. You are already processing it in your code. Also, in your example, you seem to have a third shortcode, … Read more
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
Add Shortcode to a Div or Header [closed]