New answers tagged

-1

Just replace your short code function with given code. Then call it as usual. It should work perfectly now. //registering the shortcode to show testimonials function load_testimonials($a){ $atts = shortcode_atts( array( 'rand' => '', 'max' => '', 'id' => '', ), $a); $args = array( "post_type" => ...


0

Yo don't need to write a plugin for that - what you need already exists. Check this link: https://wordpress.org/plugins/list-categories/ With this plugin you can display categories in any post or page. Of course, maybe you want to write your own plugin, and in that case this link can be helpful. I hope that this will help you to speed up a process.


0

I've modified your code to reflect the wp_list_categories() function reference as suggested by @Usce. This snippet will create an unordered list, remove the "Categories" list title, and add the li class with individual category ID so you can target each link in the list. function catting ($atts, $content = null) { echo '<div id="cats" ...


-1

There is build in wordpress function for that , so you can use wp_list_categories() for that. Please refer here to learn more And after you display them you an do some CSS if you want to display it as buttons. I hope this helps. Kind regards, Usce


0

Solution I find a workaround for this issue. I post it for posterity. This is an issue, several issue, between divi and REST Api. In the exemple bellow, register_rest_field is used instead of register_rest_route, but the fix is valid for both method. This solution could not be very futureproof. But, at least, their is no modification inside Divi Builder ...


5

For the permanent solution, your SQL query is slightly off - you need: UPDATE db1357924680.wp_posts SET post_content = REPLACE( post_content, '[print_me]', '' ) WHERE post_content LIKE '%[print_me]%' MySQL replace example


3

There is an easier way to do this: add_filter( 'the_content', 'my_post_content_remove_shortcodes', 0 ); function my_post_content_remove_shortcodes( $content ) { /* Create an array of all the shortcode tags. */ $shortcode_tags = array( 'shortcode_1', 'shortcode_2', 'shortcode_3' ); /* Loop through the shortcodes and ...


0

Based on your updated question and comments, this should be what you are looking for: function wpse_225078_wpbd_tags( $tags ) { $tags['one_time_link'] = one_time_link(); return $tags; } add_filter( 'wpbe_tags', 'wpse_225078_wpbd_tags' ); The idea is to hook into the tag system provided by WPBE so you can just use %one_time_link% in your email ...


0

Availability of shortcodes defined by plugins at any point of the code is undefined expect for (and even that is a maybe) singular content. In most cases outside of that context you better call the function implementing it with the applicable parameters instead of "parsing" the shortcode.


1

To enable shortcodes in text widgets add a filter like that: add_filter( 'widget_text', 'do_shortcode' ); You can pass every string to do_shortcode() including get_theme_mod() calls. echo do_shortcode( get_theme_mod( 'theme_setting' ) );


-1

Shortcodes are intended to return values, or echo them. You can use the include to the file you have, but unless you serve the intended $atts to the function there you won't see anything. Basically no one can help you unless we see the rest of your code. My best guess is that you need to declare the variable globally from the attributes in the shortcode and ...


1

You are probably confused by the output of array_values() which will always get you only array values without keys while $atts variable is actually an associative array. To extract your attribute use $arr = $atts['tablepageid']; Cheers


1

Your shortcode should look something like that function se224467_shotcode_star_rating( $atts ) { $a = shortcode_atts( array( 'grade' => 5, ), $atts ); $full_stars = floor( $a['grade'] ); // full stars $output = str_repeat( '<i class="fa fa-star"></i>', $full_stars ); // if not a whole number append a halt ...


0

I think you are looking for this- function star_rating( $atts ) { $max = 5; $atts = shortcode_atts( array( 'grade' => $max, // default ), $atts ); $star_icons = ''; $full_star = floor( $atts['grade'] ); for( $i=1; $i<=$full_star; $i++ ) { $star_icons .= '<i class="fa fa-star"></i>'; } $half_star = 0; if( (int) ...


0

If you have a look at how [dj-widget] shortcode is handled you will get an idea of how to implement plugin authors' idea of showing post description. if($show_desc) { $desc_string = station_shorten_string(strip_tags($show->post_content), 20); $output .= '<span ...


0

You can do this by using 'the_content' filter. That way, Wordpress will treat the content as it was came from the editor field and execute all the shortcodes: <?php $meta = get_post_meta($post->ID, 'intSlider', true); ?> <div id="sliderWrap"> <div id="slider" class="floatLeft"> <? echo apply_filters('the_content', $meta); ...


0

I played around with the plugin files and was able to figure it out myself. For anyone who's wondering, you can use wp_insert_post. You just need to find what variable the generated shortcode is stored in, which can take a little digging through the plugin files. For the plugin I was working with, it went something like this: $my_poll = array( ...


0

It seems that I found a solution to this and it is pretty easy. So I'm gonna post all the code for future uses: single.php <?php get_header(); ?> <?php $post = get_post(); $post_cat = get_the_category($post); $data = collection_data_json($post_cat[0]->term_id, $post->ID); $data_details = collection_order_permalink($data); $author_id = ...


0

I would call your use of shortcode nesting as a bad idea, therefor what you really need is a rethinking of your strategy. It is not bad by itself to nest shortcodes, but shortcodes should be independent entities and in your structure the inner ones will obviously depend on being "inner" and will not have any use by themselves. One wrong copy and paste, one ...


0

For nested shortcode, you must do_shortcode for your $content. function makeTitle( $atts, $content ) { ob_start(); ?> <h2> <?php echo do_shortcode( $content ); ?> </h2> <?php return ob_get_clean(); }


0

You can write a wrap function for short code like that. function simplest_shortcode_ever() { ob_start(); ?> Your PHP Logic here <?php return ob_get_clean(); } add_shortcode( 'simple_shortcode', 'simplest_shortcode_ever' ); And then use it[simple_shortcode]


-1

Use do shortcode: <?php echo do_shortcode('[yourshortcode]'); ?>


0

Using do_shortcode within a shortcode does the trick of parsing the inner shortcodes. More information here: https://developer.wordpress.org/reference/functions/do_shortcode/


2

Shortcodes are expected to return content, not echo it out. So if your shortcode_file.php file is straight html, it's considered being echoed. If that's the case, you could do something like : function shortcode_name(){ ob_start(); require_once ( plugin_dir_path(__FILE__) . '/shortcode_file.php'); $content = ob_get_clean(); return ...


0

Image fix You are using the incorrect function to return the image source url. Change the_post_thumbnail_url( $post["ID"] ) to get_the_post_thumbnail_url( $post["ID"] ) see https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/ To fix the echo Use a $return variable like so: $out = '<div class="recent-posts">'; $out ...


1

You can add a Shortcode using the built-in text widget. To get the widget to process Shortcodes, add the following filter in your theme's functions.php: add_filter( 'widget_text', 'do_shortcode' ); This will result in widget text being passed thru do_shortcode, which will render any Shortcodes embedded in the text. Just note that this may not work for all ...


0

You can find more information in the Widgets API


0

Okay here are the solutions for my problems here for the people having the same problem. 1 - First problem was I was unable to get the shortcode to work in multiple instances and that was because I used include_once at the shortcode function instead of include to include the separate php template. 2 - The second problem was that when I mapped my shortcode ...



Top 50 recent answers are included