How to display Custom Post Type Post based on Tag with Shortcode Parameter?

This is an answer that depending on how you ultimately configure things – should get you where you want to go. In your question, you had posts_per_page as 1. If you only want 1 result, then that’s fine. If not… modify as shown. You also didn’t initialize the concatenated string $return_string and finally you put … Read more

How to link to current post in WordPress?

This is exactly the type of scenario shortcodes are intended for. Simply add the following to your theme’s functions file to create the shortcode: add_shortcode( ‘this_permalink’, ‘this_permalink’ ); function this_permalink($atts, $content){ return ‘<a href=”‘. get_the_permalink() .'”>Link to this article</a>’; } .. and use this in your post to render the link: [this_permalink] I cannot think … Read more

Where to call add_shortcode function in WordPress Plugin Boilerplate?

If you look at the /includes/class-plugin-loader.php you will see the public function add_shortcode( $tag, $component, $callback, $priority = 10, $accepted_args = 2 ) { $this->shortcodes = $this->add( $this->shortcodes, $tag, $component, $callback, $priority, $accepted_args ); } That builds a list of shortcodes to be registered with WordPress. You use that via /includes/class-plugin.php within this function: /** … Read more

stop shortcode stripping in category and archive pages

Shortcodes are stripped from the excerpt before filters are applied. Try something more like this: function tsc_execute_shortcodes_in_excerpts( $text, $raw_text ){ if(empty($raw_text)){ $text = get_the_content(”); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); $text = strip_tags($text); $excerpt_length = apply_filters(‘excerpt_length’, 55); $excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘[…]’); $words = preg_split(“/[\n\r\t ]+/”, $text, $excerpt_length + 1, … Read more

Shortcode content filter?

you can use regex to find your the src and use that to append your “files/myimagescript?” to it: function append_myimagescript($attr, $content){ $pattern = ‘/src=”https://wordpress.stackexchange.com/questions/11618/([^”]*)”/i’; $replacement=”files/myimagescript?${1}”; return preg_replace($pattern, $replacement, $content); }

Any Short code Availble for Get Post List With Thumbnail Plugin?

here is a quick crack at making it a shortcode paste this code in your theme’s functions.php file: add_shortcode(‘gplt’,’getPostListThumbs_shortcode’); function getPostListThumbs_shortcode($atts, $content = null){ extract(shortcode_atts(array( ‘orient’ => ‘v’, ‘imgo’ => false, ‘ttgo’ => false, ‘dtgo’ => false, ‘dtfrm’ => 1, ‘categ’ => ”, ‘postnr’ => 20, ‘linn’ => 3, ‘tbwid’ => 40, ‘tbhig’ => 40 … Read more

Custom CSS for plugin form

you can check with the_posts hook if your shortcode exists and only enqueue the style if so : function check_for_shortcode($posts) { if ( empty($posts) ) return $posts; $found = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[CHANGE_TO_YOUR_SHORT_CODE’) ) $found = true; break; } if ($found){ $url = get_bloginfo( ‘template_directory’ ); wp_enqueue_style( ‘my_login_Stylesheet’,$url.’/my_login_Stylesheet.css’ ); … Read more