How to use shortcode attribute in separate function

To be able to use a variable that is essentially being created within the shortcode function, you’ll need to store it somewhere and then retrieve the value. WordPress does use global variables internally to store and carry across values, but I wouldn’t advise you do the same though. Read about the options API here. Pretty … Read more

How do i get (unique) page name?

The WP global variable $pagename should be available for you, I have just tried with the same setup you specified. $pagename is defined in the file wp-includes/theme.php, inside the function get_page_template(), which is of course called before your page theme files are parsed, so it is available at any point inside your templates for pages. … Read more

Audio and video shortcodes not working properly

Okay, there are two things going on. First, since you are running WordPress 3.6, you don’t need to run any other media player plugins. Deactivate Widgetkit and use the following shortcode to add your audio player: The reason you aren’t seeing the play button on your players is that your web server is not serving … Read more

Convert shortcode into html form [closed]

First off, your shortcodes are not formatted correctly for WordPress. You need to have a tag for your shortcode and then define the attributes separately. Instead of [list-style=”one”][/list-style] it needs to be something like [list class=”one”][/list] The following code will add two shortcodes to your WordPress install. [list] and [li] // shortcode for the list … Read more

esc_attr not working in shortcode

I think I have figured out the problem, though I have yet to solve it. I am running the shortcode in a WP Types custom WYSIWYG field. The shortcode works perfectly everywhere else, including directly in my theme files and in the native WordPress content WYSIWYG, so it seems it is a bug in WP … Read more

Adding shortcode to the main menu

I thought about making this a plugin since so many people ask about it, but here’s what you can do. This is by far the most consistent option that I’ve found because it allows you to do virtually anything you want in menus and doesn’t require writing your own walker class. Install stag custom sidebars … Read more