Remove images from get_the_excerpt

If you read the Codex entry for get_the_excerpt(), you will find this: If the post does not have an excerpt, this function applies wp_trim_excerpt to the post content and returns that generated string with “[…]” at the end. wp_trim_excerpt is applied via the get_the_excerpt filter and can be removed. The wp_trim_excerpt() function: Generates an excerpt … Read more

Nested Shortcode Inside [caption] Doesn’t Process

There is a hook inside the caption shortcode that will allow you to hijack the whole thing. Most of the following is copied from the Core img_caption_shortcode function. function nested_img_caption_shortcode($nada, $attr, $content = null) { extract( shortcode_atts( array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ => ” ), $attr, ‘caption’ ) ); … Read more

How do I add my own custom shortcodes?

Shortcodes work via Shortcode API. Essentially shortcode is just a human-friendly form of writing out data that is processed and passed to associated PHP function. So adding your own shortcode involves: Coding PHP function that would process data, passed by API from shortcode. Registering that function as shortcode handler. I also remember WP Utility Short … Read more

Run shortcode at certain resolution

Ok, let’s clarify the concept. You don’t want download the content for mobile device, and you want to rely on screen resolution. You know that php (wordpress) run on server, screen resolution is a completely client-side matter. So the flow will be: user send a request to your site your site page load on client … Read more

display shortcodes outside of the_content

You can use the function do_shortcode() for use shortcodes outside fomr default content. You can also parse this in your function, there get the output of your textfields, like the follow example for a custom field: if ( get_post_meta( $post->ID, ‘cfield’, TRUE ) ) echo do_shortcode( get_post_meta( $post->ID, ‘cfield’, $single = TRUE ) );

Why does WP not like my container?

I think it’s safe to say that wpautop() is a basket case without hurting anyone’s feelings, but I wouldn’t remove & add it at a different priority as that just makes things worse, as demonstrated (although what you posted is the browser trying to make sense of broken html, rather than the actual output, which … Read more

How to return a string that has a variable inside in a shortcode?

When you want to return a data combined with a string, you can use one of the following methods: Either open and close the string using ‘: return ‘<span class=”class2″ id=”class3-‘ . $random . ‘”> </span>’; Or use the double quote: return “<span class=”class2″ id=’class3-{$random}’> </span>”; You can simply use $random without the {} curly … Read more

WP_Query in a shortcode

When you are constructing the $output variable, you need to consider get_the_post_thumbnail() get_the_excerpt() get_the_content() get_permalink() that return the values instead of the_post_thumbnail() the_excerpt() the_content() the_permalink() that echo the values.