Query to list all galleries under a parent post?
I had to set the post type in the query. ‘post_type’ => ‘gallery’ Problem solved!
I had to set the post type in the query. ‘post_type’ => ‘gallery’ Problem solved!
This will not work in the post content context because filter for wpauto is executed before the shortcodes are processed. So, your shortcode tries to disable wpauto filter, but that filter was already executed on that content. You can do with this (in theme functions.php file, and similar for excerpt): add_action(‘the_content’, ‘wse_281097_content_remove_wpautop’, 1); function wse_281097_content_remove_wpautop() … Read more
Problem 1 It doesn’t work because you’re using new_weber but you’re registering news_burner, and they aren’t the same So instead use: [news_burner] You only need a closing shortcode if it’s containing content which that plugin does not. Problem 2 Shortcodes don’t work in text widgets out of the box, you can add that functionality via … Read more
You’re returning X(), but your X() function appears to be within a class. Presumably the same class as handleShortcode(). So you need to call it the normal way you call functions within a class: public function handleShortcode($atts) { return $this->X(); } private function X() { return ‘Hi world’; } If you’re not in a class … Read more
In your function mailchimp_form_shortcode(), you need to do following changes (specifically first line inside the function): <?php function mailchimp_form_shortcode($atts) { extract(shortcode_atts(array(), $atts)); if(isset($attrs[‘type’]) && $attrs[‘type’] == ‘some_value’){ //return “form element”; } } add_shortcode(‘mailchimp’, ‘mailchimp_form_shortcode’); ?> and your shortcode will be as: [mailchimp type=”some_value”] By this, you can pass parameters to your shortcode function. And inside … Read more
Here is the correct shortcode function function section_shortcode_func( $atts, $content = null ){ $atts = shortcode_atts( array( ‘bgimage’ => ” ), $atts); $bgimage = isset( $atts[‘bgimage’] ) ? $atts[‘bgimage’] : ”; ob_start(); echo “<div class=”section” style=”background-image: url($bgimage)”>”; return ob_get_clean(); } Now you can call it this way [section bgimage=”xxx.xxx/wp-content/uploads/2017/10/xxx.jpg”]
You can save your website’s URL into a variable and pass it to the shortcode: $url = site_url(); echo do_shortcode(“[timeline src=”https://wordpress.stackexchange.com/questions/284281/$url/rest-of-the-url/”]”); You should also be able to use your shortcode in the following way: echo do_shortcode(“[timeline src=””.site_url().”/rest-of-the-url/”]”);
Shortcodes are intended to be used by humans, to be some kind of macro that even the most techno-phobic author can use. If you need to have arrays of attributes, or any other complex structure for which the author has to attend CS 101 in order to understand its use, your shortcode is just a … Read more
This should work global $post; $html = “”; $my_latest_posts_widget = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3 )); $html .= ‘<div id=”container_recent_posts_widget” class=”container_recent_posts_widget”>’; if( $my_latest_posts_widget->have_posts() ) : while( $my_latest_posts_widget->have_posts() ) : $my_latest_posts_widget->the_post(); $thumb = get_template_directory_uri() .’/assets/images/default-image-post-thumbnail-widget.jpg’; if ( has_post_thumbnail() ) { //override fallback image if post has any thumbnail $thumb = get_the_post_thumbnail_url(); } … Read more
They’re may be a more parsimonious way to achieve what you want, maybe with jQuery or a more heavily customized version of the code, but just keeping to WordPress core functions, you could try the following approach, which utilizes the wp_audio_shortcode_override filter. I tested a version of the below using is_page() for the main conditional. … Read more