Tag Info

New answers tagged

1

Auto-generate shortcodes from an array: You can try the following Shortcode Automat: /** * Setup the Shortcode Automat * */ function shortcode_automat_setup() { $settings = array( "get_address" => "mg_admin_address", "get_phone" => "mg_admin_phone", "get_fax" => "mg_admin_fax", "get_email" ...


-2

Plugins are to extend and add to the functionality that already exists in WordPress. you can create your own.


-2

Plugins is a centralized solution. You can implement your functionality via theme. use : wp_enqueue_script, wp_enqueue_style


0

Plugins usually increases the site functionality and performances.We can add additional plugins for doing some features that are not in basic wordpress.


1

You should try this on a default theme (without any plugins), to see if that makes any difference. Your shortcode example: [caption id="my-caption-id" class="my-caption-class" align="alignnone" width="399"] <img src="whatever.jpg" alt="whatever" width="399" height="600" /> My caption text [/caption] gives this output: <div ...


0

The do_shortcode function requires it to be echoed. I just ran your code against my test site, and was able to get a shortcode to display test. Try this in your code echo do_shortcode("[download-attachments]"); Edit: Here's my test function that works for me: function wpse_158314() { if ((is_home()) || (is_front_page())) { $query_brands = new ...


1

I am also seeking the same solution. I am going to create a gallery filter function - an extension to this. Do you want to collaborate? function get_post_gallery( $post = 0, $html = true ) { $galleries = get_post_galleries( $post, $html ); $gallery = reset( $galleries ); /** * Filter the first-found post gallery. * * @since 3.6.0 * * @param array ...


2

If you have a function that you cannot change to prevent the premature output, you can still override the shortcode handler: add_shortcode( 'wordpress_social_login', 'wordpress_social_login_fix' ); function wordpress_social_login_fix( $attributes, $content ) { ob_start(); wsl_render_login_form(); return ob_get_clean(); }


0

You need to capture the attributes that passed to a shortcode. You can do that like this add_shortcode('testimonial', 'testimonial_shortcode_func'); function testimonial_shortcode_func( $atts ) { $atts = shortcode_atts( array( 'style' => 'default_value_if_no_value_is_provided', ), $atts ); if( $atts['style'] == 'fancy' ) { //do ...


0

As indicated in the comments, you should return the string, not echo it: add_shortcode('yt', 'getYoutubeDetails'); function getYoutubeDetails($atts) { extract(shortcode_atts(array( 'video' => '' ), $atts)); // Get YouTube data via the API $JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos?q=$video&alt=json"); ...


0

A possible solution, a good one I think, is to use a object with a property to store the validation status so you set the value of this property in the init action hook where you process the form and access to it in the shortcode. For example: class MyForm { private $validate; function __construct() { add_shortcode( 'myform', array($this, ...


0

Your functions have nothing to do with each other. Is all you want a button that when clicked adds [tooltips class="top_tooltip" title="Your Tooltip here"] Text here [/tooltip] to the editor? -- This is currently what your doing -- First Function: function tooltip( $button ) is adding your tooltip shortcode Second Function: mce_tooltip( $button ) is ...


1

You have to rely on javascript for the redirect. You can set it like this in your shortcode. $html = "<script> location.href = " . $home_url() . " </script>"; return $html; It will load the page and then redirect immediately.


0

Based on what I can see, it looks like your calling the create_map function incorrectly. add_shortcode() takes 2 parameters, the name of the shortcode and the function that gets rendered when called. The array you are passing is how to call a method inside of a class. You're basically saying call the create_map method from the hotSpot class. Assuming this ...


1

First, create a function to process the form. In the shortcode function, first process the form and then return any form/message that you want to display to the user. /** * Plugin Name: NewsletterFormConnector * Description: Newsletter Form to connect to Newsletter Api * Author: emjay * Version: 1.0 */ //Add function file ...


0

First of all, never use anonymous functions, never. Anonymous functions can't be removed later by plugins or themes Secondly, have a look at the Shortcode API on how to properly create a shortcode. Thirdly, this is not a wordpress specific problem, but pure php. You are using html and php together without the proper syntax to differentiate between html and ...


0

The error you are receiving and most likely the reason it isnt working is because of your shortcode function. It looks like you are trying to redeclare php inside of the return. Try this (notice I dont have the function ads_one_shortcode($content = null) { $options = get_option( 'theme_settings' ); return '<div> ' . ...


0

$html . = echo '' . $my_theme['social-twitter']; will throw the error. because syntax is wrong. you will try this: $html.= ' ' . $my_theme['social-twitter'];


0

'echo' statement will not work in shortcode function. shortcode function is just returning the variable; So your code will be like this: if(get_field('group')) { $html = ''; $html.= "<ul class='sponsors'><h2>" , get_the_title() , "</h2>"; while(has_sub_field('group')) { $attachment_id = get_sub_field('image'); ...


0

You're using it twice differently, but you're not creating a unique transient name, so the second time the shortcode runs it just uses whatever was saved in the transient the first time the shortcode ran. Come up with some way to uniquely identify the transient, like: set_transient( 'shortcode_post_' . sanitize_key( $a['name'] ), $shortcode_post, 60*60*4 ...



Top 50 recent answers are included