Tag Info

New answers tagged

0

I wrote a php script for it, is not a wordpress plugin source code here : https://github.com/salsan/FeedCountText Require you active FeedCount on your account of FeedBurner Example Mashable http://feedcounttext.appspot.com/FeedContText.php?uri=http://feeds.feedburner.com/~fc/Mashable


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


0

You might want to check : https://wordpress.org/plugins/tabsy/ . I'm using similar shortcode layout. I hope this helps. Thanks! Cheers, phpbits


-2

my solution : do_shortcode(html_entity_decode($content)) But not working with ' & " :/


1

Using your example I've updated it to return instead of the title the image. function post_shortcode( $atts ) { extract( shortcode_atts( array( 'id' => '', ), $atts ) ); if ( isset( $id ) ) { return '<a href="' . get_permalink( $id ) . '">' . ...


0

You can simply do it like this: // shortcode hook add_shortcode("make-me-a-map", "create_new_map"); // shortcode callback function style_my_new_map() { global $new_map_called_for; if ($new_map_called_for == true) { wp_register_script('make-a-new-map', get_template_directory_uri() . '/js/new-map.js', array('jquery'), '0.1', true); ...


0

ave you tried to put it in the Shortcode-function? I would suggest this: function my_shortcode() { ?> <script> alert('test') </script> <?php } add_shortcode( 'my_shortcode', 'my_shortcode');


2

You don't specify where exactly the error comes from but I assume your problem is that you assign an object to the slug instead of a string. your code should look like $t = array_shift( $terms ); $params['slug'] = $t->slug;


1

Try https://wordpress.org/plugins/shortcode-empty-paragraph-fix/ It basically removes any p-tags before and after [ or ], before rendering the content. So the output of your shortcodes won't be wrapped in p-tags


0

@Jon, I know that that's probably more to comments, but I don't have enough reputation: Are you sure, that your theme supports shortcodes? Have you tried another ones (f.ex. Shortcodes Ultimate)? Because if they don't work you have to allow them first ;) You haven't said if you're developing a theme or using some from someone else.


2

Shortcodes get replaced when you output the content via the_content() function, or apply the filters hooked to the_content. If you look at raw post data, you will always see the original shortcode placeholder, that is normal and expected.


1

So this turned out to be the problem: After running using WP_DEBUG on the live site it turned out $this was not defined in the following line: public function __construct(){ add_action('init', function(){ add_shortcode('bbit', array($this, 'shortcode_handler')); }); } shortcode_handler is a non-static function here, and this code was all ...


1

When you set the third parameter of get_post_meta to true, the function returns a string, as you can read in the codex. So: $arr = get_post_meta($post->ID, 'tab_details', true); Makes $arr be a string and a string is not a valid argument for a PHP foreach loop and that is waht the error message says. Instead, if you set the third parameter to false or ...


2

I am a little confused as to your question. If you know how to create shortcodes with attributes, then I think the answer to your question is to simply output text with the correct attributes predefined. For example, just add text into your custom column for the appropriate arguments, such as echo "[book id=" . $post->ID . "]". The shortcode isn't ...


1

In order to get your shortcode to show up, you have to register it first. This is done with add_shortcode(). You can read more about the Shortcode API in the Codex. Here is an example of a Youtube video-shortcode that accepts 3 parameters; Video ID (from Youtube, the last part of the Youtube url), height and width. This would go into your functions.php ...


0

It seems the function is broken. The issue is in trac: https://core.trac.wordpress.org/ticket/14050 I am using this to solve the problem temporarily: https://core.trac.wordpress.org/attachment/ticket/14050/plugin.php . This code still fails some of the tests used, but it completely resolves the issue I described, so I will use it unless I find something ...


0

I've been reading the WordPress documentation about this function and the behaviour you are having there, is the one expected to happen. This function clean outside of the shortcode and not inside. The regex is not checking the content of the shortcode. EDIT: https://developer.wordpress.org/reference/functions/shortcode_unautop/ Don’t auto-p wrap ...


1

This part of the code is what defines the arguments that can be passed with the shortcode: extract(shortcode_atts(array( "posts" => '8', "columns" => '4', "category" => '', "style" => 'text-normal', "image_height" => 'auto', "show_date" => 'true', "excerpt" => 'true', ), ...


1

Haven't actually seen plugins with 30 shortcodes, but my opinion on this is, it is too much and I would really want to know what are all these shortcodes for. To come back to the actual issue, shortcodes is slower than normal functions because they need to be parsed. This differences should be minute though. The real performance issues comes in when it come ...


0

You can register a new widget in your functions file. Best to create a child theme for code additions and modifications. You can call the new sidebar in your single.php or content.php file (recommended for themes without custom hooks) Or Use a custom function with the is_singular('post') conditional tag in your functions file and return the sidebar ...


0

I finally make it ready after some more research. function coregnie_list_ul( $atts, $content = null ) { extract(shortcode_atts(array( 'style' => 'cg_list', ), $atts)); return '<ul class=cg_list_'.$style.' >'.do_shortcode($content).'</ul>'; } add_shortcode('ul', 'coregnie_list_ul'); function coregnie_list_li( $atts, $content = null ) { ...


0

You could use more appropriate path, like: $path = ABSPATH . WPINC . '/js/tinymce/tiny_mce_popup.js' And you should use wp_enqueue_script, so you could put something like this: wp_enqueue_script('my-tinymce-popup', $path);


1

When you look at how do_shortcode() actually works, then it's this: do_shortcode( $content ) Where $content is defined as the following: (string) Content to search for shortcodes What you are trying to do is to echo what the shortcode does, leading to a false assumption. There is no magic function discovering your shortcode. The shortcode simply is ...


0

this will work with an theme but a couple things to note, the code is looking for a custom post type of 'event' and it is sorting the order of the events by 'event_start_date' if you were to change those to match whatever plugin you are using you could totally use it! you could also add those as attributes in the the shortcode itself but i am not a huge fan ...


0

Because I was trying to make the redirect happen using shortcode in the registration and I didn't get the answer which can delay the redirect until I add custom textarea fields date to user profile page before this step $userID = wp_insert_user( $userDataArr ) , I have no user ID yet, so I can't do update for unknown user id after it the redirect happens ...


0

Version #1 The following seems to work for the Twenty Fifteen theme: /** * Display the comment form via shortcode on singular pages * Remove the default comment form. * Hide the unwanted "Comments are closed" message with CSS. * * @see http://wordpress.stackexchange.com/a/177289/26350 */ add_shortcode( 'wpse_comment_form', function( $atts = array(), ...


0

Just by looking at your code I see a few places I'd investigate. 1) I don't see any use of the $atts that come through the shortcode. Specifically the 'tax' and 'post_per_page' attributes. So try changing this; 'tax' => '', to this: 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', ...


0

To add to the answers in the comments from RH, I found this in the codex (it's kind of burried deep): Shortcode attribute names are always converted to lowercase before they are passed into the handler function. Values are untouched. This is from: http://codex.wordpress.org/Function_Reference/add_shortcode#Parameters


2

You need to escape your quotes, or use doubles, or use heredoc: // Escaped return '<div id="xxxx-xxxxxx"></div> <script type="text/javascript"> window._taboola = window._taboola || []; _taboola.push({ mode: \'xxxxxxx-xxxxx\', container: \'xxxxxx-xxxxxxx\', placement: \'one word word\', target_type: ...



Top 50 recent answers are included