Using Echo in ShortCode – Stuck

You can also use output buffering to catch all output you generate. Use it like following: function fl_aries_co_today_shortcode() { global $wpdb; $results = $wpdb->get_results(“SELECT horoscope FROM wpaa_scope_co WHERE date = CURDATE() AND sign = ‘aries'”); ob_start(); foreach($results as $r) { echo “”.$r->horoscope.””; } $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode( ‘fl_aries_co_today’,’fl_aries_co_today_shortcode’ );

Can’t seem to get [shortcode]s to work

As Milo indicated: functions.php is a file within your current theme, not the functions.php file in wp-includes. There’s nothing wrong with your code as-is as long as it’s in a file that’s actually being loaded at the correct time. Addressing your other question from the comments, yes, this code can be wrapped up into a … Read more

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