Tag Info

New answers tagged

1

I don't know exactly what you are trying to do but perhaps something like this: function customfields_shortcode( $atts ) { if (!empty($atts['field']) && get_post_meta( get_the_ID(), $atts['field'], true ) ) { $customfield = get_post_meta( get_the_ID(), $atts['field'], true ); return "custom field >> $customfield << custom ...


4

If you want to do this via AJAX, on the server side you could do something like the following: add_action( 'wp_ajax_nopriv_update_shortcode_content', 'update_shortcode_content' ); function update_shortcode_content(){ if( !empty( $_GET['new_shortcode_value'] ) ){ $updated_content = do_shortcode( '[theshortcode value="' . ...


0

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 shortocde, are you sure it's most ...


0

You can also go with aq_resize function. There are second and third arguments are given for size, so you can give any size that's you want. Even you can also set these size using shortcode. Check how to pass arguments to shortcode and pass using shortcode if want to fetch dynamic size for each time function thumb_medium( $atts, $content = null ) { ...


2

I think your code is very close, try to use wp_get_attachment_image_src() instead: function thumb_medium( $atts, $content = null ) { // return wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'medium') ); global $post; $thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' )[0]; if ($thumb_url) { ...


0

Try removing the brackets and adding the full url: $url = 'http://theurl.com'; And for clarity, it's best to use different names for the tag and function name: add_shortcode('aggrenda', 'aggrenda_func'); function aggrenda_func() { $url = 'http://theurl.com'; $response = wp_remote_get( $url ); echo($response); }


0

Simply you need to replace the_field('video') with get_field('video'). Why? Because according to ACF documentation; get_field($field_name, $post_id, $format_value) Returns the value of the specified field. Whereas on the other hand the_field($field_name, $post_id) Displays the value of the specified field. (this is the same as “echo ...


0

I figured out the issue. I'm leaving the answer for future reference. Turns out IE needs you to include all the HTML tags for the video to load correctly when using flash. This is my working code now: <?php define('WP_USE_THEMES', false); require('../wp-load.php'); echo '<!doctype html>'; echo '<html>'; echo ...


0

At first glance, you're assigning values to get_current_blog_id instead of comparing them. That is get_current_blog_id() = 1 should be get_current_blog_id() === 1 in both places.


1

WordPress 4.2.3 made some changes to the way shortcodes work in order to fix a security issue. See here: https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/ This is most likely the cause of your problem. See the Shortcodes with Bad Quotes section, and the accompanying workaround suggestion.


0

To answer the heart of your question: no, WordPress does not have a way of referencing posts by ID/slug/etc. within the post content. In fact, probably the recommended way to do that is with a...shortcode! Even that wouldn't help you in this case, though, since you can't nest shortcodes without a plugin. So I'd recommend you use your own shortcode, or plug ...


0

Assuming that $GLOBALS['Pootle_Page_Builder_Render_Layout'] carries an instance of Pootle_Page_Builder_Render_Layout, the method panels_render() returns a string. So you can simply pass the method call as an argument to apply_filters(): $content = apply_filters( 'the_content', $GLOBALS['Pootle_Page_Builder_Render_Layout']->panels_render( ...


3

Just use do_shortcode: echo '<div class="wrap">'. do_shortcode( $two ) .'</div>';


0

Ok I had the format wrong. It works as [category foo,foo2] adding to both cats or creating one if it didn't already exist. Ta.


0

I believe that is only a feature in wordpress.com blogs. You probably want to use a plugin like Postie to get the functionality you're looking for.


1

Building on the accepted answer and filling in some details... You need to call wp_localize script right after wp_enqueue_script. So, something like this: function my_enqueue_scripts() { wp_enqueue_script( 'myjs', plugins_url( 'js/my.js', __FILE__) ); $options = get_option( 'my_settings' ); $scriptData = array( ...


0

the shortcodes doesn't shop up in the liste because it's not a valid declaration with a valid function callback on the 2nd argument try this to see what append : // shortcode data add_filter("shortcode_list", function ($shortcode_list) { $shortcode_list["slugA"] = array( "html" => "test html 1", ); return $shortcode_list; }); ...


1

to have the good path to the file, try this : $array = file(plugin_dir_path(__FILE__) . "quotes.txt");


0

Few months ago I was working on a similar thing where I had to generate short codes dynamically. But I took a different approach. What I did was as following; I registered a short code and custom post type for which I had to use that dynamic short code. Then added attribute for post name (slug) in that short code to get data dynamically to display on ...


0

You can handle this by other way. <?php function my_title( ){ $title = get_the_title(); return 'page_title="' . $title . '"'; } add_shortcode( 'page_title', 'my_title' ); function input_shortcode($atts = null ) { extract( shortcode_atts( array('page_title' => 'page_title'), $atts ) ); return "<input type=hidden name=itemname ...


0

Maybe you're looking for do_shortcode(), which simply executes a shortcode? Reference: https://developer.wordpress.org/reference/functions/do_shortcode/ Still, executing a shortcode within a shortcode sounds weird. You should better make your old (first) shortcode a PHP function and then just call it from each shortcode.


1

Your have two major issues here The string you are building is correct, but it gets overriden on each iteration of the loop, which at the end will only hold the info from the last post. You need to define your variable outside the loop and then concatenate your info to that variable across the entire loop in order for you to display all postdata from all ...


0

i used a function from @HOWDY_MCGEE 's answer plus some rewrites and attahced is my working code. functions.php: function pw_show_gallery_image_urls() { global $post; // Make sure the post has a gallery in it if( ! has_shortcode( $post->post_content, 'gallery' ) ) // return $content; return 'nadagif'; // Retrieve the first gallery ...



Top 50 recent answers are included