Tag Info

New answers tagged

0

The do_shortcode function runs on the the_content hook: 402 403 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/shortcodes.php#L403 So, without seeing your theme code I am going to guess that your theme's archive page is written in such a way that the ...


0

Okay, so found the solution (sorry for the delay) I had to put this: // Add Shortcode function city_name() { global $current_cityinfo; return ' '.$current_cityinfo['cityname']; } add_shortcode( 'city name', 'city_name' );


0

Use a double third brackets then. In visual editor: [[my-shortcode]] To show shortcode as a code, in HTML/Text mode: <code>[[my-shortcode]]</code> And you can even write anything with a third bracket in this way: Do something [[once]] and go... *suggested by SergeyBiryukov


1

It seems that you might have a lot of these .csv files. I would suggest to use only one attribute and then passing the appropriate name to that attribute or the prefix of the file name and then building the file name from there. You can try one of the following (I have not done any verification, you will propbably check that the attribute is not empty and ...


1

You could just echo do_shortcode( $content ); Function Reference/do shortcode


1

As I already stated in comments, extract() should never be used. It was removed from core and the codex for very specific reasons and the use there of is strictly not recommended in future applications and functions. Please see trac ticket #22400 for complete details. As stated before, the codex was also updated accordingly, so you can look at the examples ...


0

You should be passing the 'cityname' to your function: function get_city_name($cityname) { return $cityname; } add_shortcode( 'city-name', 'get_city_name' ); Your shortcode would then look like: [city-name cityname="London"] chances are that your function will return an array, but this should help you move forward


1

You need to get $current_cityinfo first. As in: $current_cityinfo = get_option('current_cityinfo'); Or add this code: global $current_cityinfo; above your return line.


-1

The $atts don't extract automatic, try this before call global $post extract(shortcode_atts(array( 'field' => '',//#Default value or null ), $atts)); This code extract $atts to single variables, see more in Codex.


0

There are multiple solutions: Use CSS for post images: .post img { height: 300px; width: auto; } Use a custom thumbnail size. Either in Settings -> Media or use a third-party plugin to generate them. Another way would be to code your own: function custom_image_sizes() { add_theme_support('post-thumbnails'); add_image_size('breaking-news', 9999, ...


0

The output from a shortcode should be returned, not echoed. Echoing output in a shortcode will have unexpected output like you are seeing. the_widget() echos its output which is causing the issue. Unfortunately there is no similar function for returning the wdget output. Luckily you can make use of a output buffer to overcome this issue. You can try ...


0

Is a plugin out of the question? Seems like that would be the exact solution to your problem.


1

Your output is expected, but before I come to the solution and why's, you have a couple of issues here You are either using query_posts or nullifying the main query global which you should never do. The give away is your loop (if (have_posts()) : while (have_posts()) : the_post();) and the use of wp_reset_query();. You should be using a proper instance of ...


1

Update for everyone visiting this thread (2015) jwplayer_tag_callback() does not work anymore, you'll get a fatal error telling you the function is not defined. Instead insert a player programmatically like this: echo JWP6_Shortcode::the_content_filter( '[jwplayer file="'. $videoUrl .'"]' ); (Found here.)


2

If it really is just for one page you could use a conditional on the_ID(); from within your shortcode class (it is a custom shortcode right?) $class = the_ID() == 213 ? "some-other-class" : ""; $myhtml = sprintf("<div class='some-class %1$s'>%2$s</div>", $class, $content); The other option is to add parameters or "attributes" to your ...


2

Wordpress already has these classes in place for you, so you can basically target a specific page in CSS without adding additional classes. Take a look at the default body_class section in the codex, and more particulary at the pages section


1

This is probably the result of the wordpress 4.0.1 security fix which changed how shortcodes are handled http://wptavern.com/wordpress-4-0-1-exposes-bad-development-practices-used-in-some-plugins. While I am not sure about the details your shortcode handling seems to match the general description of trying to parse the shortcode by yourself instead of ...


0

You can run the text through do_shortcode: echo do_shortcode( $your_text_with_shortcodes ); or you can apply the_content filters to the text, which does the same thing as above along with some additional formatting goodies, like auto paragraphs and texturize: echo apply_filters('the_content', $your_text_with_shortcodes);


0

Using &#91 tag will not work if you switch between the text and visual editor. The [[shortcode]] solution does not work either with WP 4.1.1. Instead, the following solution works: [[shortcode] Hello World [/shortcode]]


2

You have used the same quotation characters in 2 different contexts. You should write the shortcode in the following way: [example text='<a href="http://example.com">lorem</a> ipsum']Lets roll[/example] Then, "unescape" HTML entities on the shortcode output: $return_string = '<div class="some-class">'. html_entity_decode($text) . ...


0

Ok mate - i got you... you should really break into 2 shortcodes. One as a wrapper (which is really short) and the other for the content... Example: add_shortcode('servicewrap', 'service_wrapsc'); function service_wrapsc($atts, $content = null) { return '<div class="service"><div class="container"><div ...


2

You need to call global $post before using $post->ID, or better, use get_the_ID() instead.


0

Two issues here Never use extract(). It has been removed from core functions, that should tell you a lot. For more info, check this trac ticket #22400 Your tax_query is incorrect, it should be an array of an array, yours is just an array Your shortcode should look something like this function course_listings( $atts ) { // Attributes $defaults ...


0

$return_string .= get_the_post_thumbnail(); should be: $return_string .= get_the_post_thumbnail( get_the_ID() );


1

I wrote a php script for it, is not a wordpress plugin , but is good point to start :) $fb_id = "Mashable"; // here your id account $fb_uri = "http://feeds.feedburner.com/~fc/"; $app_uri = "http://feedcounttext.appspot.com/?uri="; $count_uri = $app_uri.$fb_uri.$fb_id; $fb_count = fopen($count_uri, "r"); echo fgets($fb_count); fclose($fb_count); source ...


0

Put this in your theme's functions.php, it will add the shortcode [child_pages]: function wpsc_child_pages($atts){ global $wp_query; $html = ''; if( empty($wp_query->post->post_parent) ) { $parent = $wp_query->post->ID; } else { $parent = $wp_query->post->post_parent; } $pages = ...


1

Shortcode's callback should return a string, not echo it. function getMyShortCode_func() { return '<div class="abc">Hello world.</div>'; }


0

Also, add these 2 lines to your functions.php file for complete and comprehensive results: add_filter('get_the_excerpt', 'shortcode_unautop'); add_filter('get_the_excerpt', 'do_shortcode');


0

You have two big issues here are a few minor ones and some room for improvement. Lets look at your major mistakes first What you have done well is to add your output to a variable and then returning the variable in the end. Shortcodes should always return their output, not echo it. What you have done wrong here is to use the wrong template tags. The the_* ...



Top 50 recent answers are included