Filter content in shortcode

The year attribute you added to shortcode [speaker_overview_2017 year=2017] will be available through $atts in this way $atts[‘year’]. I assume, you want to do a meta query and the key is speakers_jaar and the value will be $atts[‘year’]. Please check the following code. When a year is set in shortcode, query will be limited to … Read more

how to add shortcode in wordpress container [duplicate]

This is most likely due to the way your shortcode is constructed. PHP scripts are run on the server before (as) the HTML is generated. Try buffering your shortcode ouput like this: function my_function( $atts ) { ob_start(); // do some stuff $code_output = ob_get_contents(); ob_end_clean(); return $code_output; } More info: https://secure.php.net/manual/en/book.outcontrol.php

Position shortcode off [duplicate]

Please try with this- /* * * Shortcode to display Post as links on Profile Pages * */ function imwz_golfs_list_function( $atts ) { if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array(‘posts_per_page’ => ‘-1′,’author’ => $current_user->ID); $author_posts = new WP_Query($author_query); ob_start(); if($author_posts->have_posts()) : echo ‘<ul>’; while($author_posts->have_posts()) : $author_posts->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/295515/<?php the_permalink(); ?>” title=”<?php … Read more

How can I list only custom shortcodes?

The linked question shows you how to get all the shortcode tags in an array. So narrowing them down to specific ones is purely a PHP question. But the answer’s simple enough. Use array_filter() on the array of tags with a callback function that uses strpos() to see if each tag contains the work you’re … Read more

redirect if shortcode exists

If you look at the source code of add_shortcode you will see this function doing little more than store the name of the shortcode in a global array. So, checking if a shortcode exists means looking it up in the array. Hence, if you want to check for a specific shortcode in the_content you must … Read more

Creating shortcode id for custom post types

Please replace the following code $string .= ‘<li>’ . get_the_title() . ‘</li>’;. to: $string .= ‘<li>’; $string .= ‘<figure>’ . get_the_post_thumbnail( null, ‘thumbnail’ ) . ‘</figure>’; $string .= ‘<h2>’ . get_the_title() . ‘</h2>’; $string .= ‘<div>’ . apply_filters( ‘the_content’, get_the_content() ) . ‘</div>’; $string .= ‘</li>’; Hope it’ll work just fine.

How can I filter tag_description()?

The filter is well hidden, but you can track it down from tag_description ($tag), which calls term_description ($term=$tag, $taxonomy = ‘post_tag’), which in turn calls get_term_field (‘description’, $tag, ‘post_tag’). And finally you get the call sanitize_term_field (‘description’, $tag->$description, $tag->tag_id, $tag->post_tag, ‘display’). Once you’re in sanitize_term_field you see a whole lot of filters. It looks like … Read more