Tag Info

Hot answers tagged

2

Untested (and can't test right now) but you ought to be able to add attributes with a filter... something like: function test_sc($atts,$content) { // echo 'test_sc'; $atts = shortcode_atts( array( 'foo' => 'no foo', 'bar' => 'default bar', ), $atts, 'testsc' ); // var_dump($atts); } ...


2

What I always do is, I search the files... So I use the "Search in files"-function in Notepad++ (which I am using) and limit the search to the directory, where I think, I will find what I am looking for. So, probably, you know already the plugins directory. You enter this information into the folder input line e.g.: ...


1

The Wordpress API documents this very thoroughly. Check it out here. And if you are feeling lazy, here is a custom generator. If you have a specific question beyond that, comment below.


1

You can create your short code just few steps. function short_codeFunction_name( $atts, $content=null ) { shortcode_atts( array(), $atts); $rowin = '<div class="row">'.do_shortcode( $content ) .'</div>'; return $rowin; } add_shortcode( "your_shortcode_name", "short_codeFunction_name" ); Then you can access [your_shortcode]Here ...


1

Shortcodes are too late to add ajax actions. Additionally, that actions would be added only if shortcode is executed, which is very unlikely to happen on a ajax request. The quickest way to make your code work is to move the add_action outside addimage() function. add_action( 'wp_ajax_wp_up', 'wp_up' ); add_action( 'wp_ajax_nopriv_wp_up', 'wp_up'); function ...


1

Using the the_posts filter: Here's one idea using the the_posts filter, that fires before setup_postdata() is activated: /** * Replace [nextpage] with <!--nextpage--> through the 'the_posts' filter. * * @see http://wordpress.stackexchange.com/a/183980/26350 */ ! is_admin() && add_filter( 'the_posts', function( $posts ) { $posts = ...


1

If I enter this shortcode: [download url="http://example.com"]Download[/download] it works fine. But you have to enter the link text as content yourself. You might have missed that, the way I read your question. Your [demo]-Shortcode throughs an error. To see this, you need to have WP_DEBUG set to true: Notice: Undefined variable: func in ...


1

I'm not quite sure what you want to do as frankly, your terminology is a bit scrambled, and you example shortcode is also quite a mess. Before I start, you should start of by checking the following very important links Shortcode API WP_Query You should first start of by defining your attributes (and their defaults) which you need to use and pass to the ...


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

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

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 ...


1

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


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

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 ...


1

I haven't looked in detail at your code, but what strikes me is your open_csv method. You have the following lines return $attributes['file']; return $attributes['type']; As your method currently stands, it stops and returns the value of file right after setting the attributes. Here is what return does in php If called from within a function, theĀ ...


1

get_the_content() returns unfiltered content, and using a shortcode you cannot use the_content() to return filtered content as you cannot echo inside a shortcode. Your best option here will be is to applying the_content filters to get_the_content(), something like: apply_filters( 'the_content', get_the_content() ); EDIT Exact usage, replace $output .= ...



Only top voted, non community-wiki answers of a minimum length are eligible