Duplicated content with custom shortcode

Solution attempt Due to @AlexanderHolsgrove‘s comment, I tried reutrning a simple string, so instead of return wpautop($content); I tried return “test return”;. This outputted the string on top of the queried post content. Which is weird, because I do not echo nor do I return the post content in any way now. So I tried … Read more

wp_editor not rendering the shortcode

You have to explicitly add shortcode evaluation to a text field for it to work. By default it is only defined for the_content and the_excerpt. If you look at the source of the first one you see this line: $content = apply_filters( ‘the_content’, $content ); Among the default filters is this one: add_filter( ‘the_content’, ‘do_shortcode’, … Read more

WordPress User ID as Shortcode

From add_shortcode …Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results… Try changing the echos in your callback to returns and see, if that helps.

Custom shortcode to display posts, first post is full

There are several issues in your code. Like, syntax error in line 4. Undefined $out variable PHP notice. And main issue is that you are not using the loop properly. In foreach, you need to use setup_postdata() and it also needs to be reset properly. Please check following. add_shortcode( ‘custom-home-posts’, function ( $atts ) { … Read more

Shortcode for Listing Users from Meta Value?

It’s a small coding mistake.. It’s not displaying anything because when there are results, the end output is always a </ul> because you’re always overwriting the $results and not appending output to the variable: $results=”<ul>”; foreach ($users as $user){ $results=”<li>” . $user->display_name . ‘</li>’; } $results=”</ul>”; So the proper code is: $results=”<ul>”; foreach ($users as … Read more

Handling PHP/HTML inside the output of a shortcode function

This is mostly working fine. You probably want quotes around your id in the window.superformIds array to ensure it’s a string. This is a bad way of going about this. With scripts and styles you want to avoid outputting them directly on the page wherever the shortcode is placed. Here’s a better method: add_action( ‘wp_enqueue_scripts’, … Read more

how can i pass this attribute in this shortcode?

You haven’t properly output them. You’ve closed the PHP tags after this: ), $atts));?> But, if you want to output a PHP variable you need to open them again, otherwise the text will just be interpreted as HTML. You also need to explicitly echo it. So, for $catheading as an example, you need to output … Read more