Wraping $content into link with shortcodes

This is a filter in WordPress called wpautop it is there to make formatting cleaner when publising posts, however when you want more control over formatting it can be a pain. It basically wraps returns in paragraphs so that the space you see in the editor is obeyed on the front end. You can disable … Read more

shortcode not working [closed]

I may have found the problem (from product_attribute) array( ‘per_page’ => ’12’, ‘columns’ => ‘4’, ‘orderby’ => ‘title’, ‘order’ => ‘asc’, ‘attribute’ => ‘asc’, ‘filter’ => ‘asc’ ) [product_attribute attribute=”color” filter=”black”] Notice the attibute is in single quotes wheras yours is in double quotes: do_shortcode (‘[product_attribute attribute=”Grams”]’); also you may need it to be in … Read more

Pros and cons of actions over shortcodes

Neither are correct. Just use show_foo(): <?php echo show_foo(); ?> The only reason to ever use shortcodes is to insert dynamic content into a page or post from within the editor (Although, these days the ‘proper’ way to do that would be with a block, although that’s more difficult). Shortcodes should not be used for … Read more

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

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