Add page title as a javacript variable to specific posts

Use a shortcode. In your plugin or theme (functions.php) add: add_action( ‘after_setup_theme’, ‘wpse_42534_add_permalink_shortcode’ ); function wpse_42534_add_permalink_shortcode() { add_shortcode( ‘permalink’, ‘get_permalink’ ); } Now, your users can use the string anywhere in the post to print the URI to the current post or page. Oh, and welcome to WordPress Stack Exchange!

Conditionally loading Facebook PHP SDK in shortcode

You can try to use the_posts filter to search for you shortcode and require the sdk, something like this: function has_my_FB_shortcode($posts) { if ( empty($posts) ) return $posts; $found = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[my_shortcode’) ){ $found = true; break; } } if ($found) require(‘path/to/facebook_sdk.php’); return $posts; } add_action(‘the_posts’, ‘has_my_FB_shortcode’);

How to load shortcode sooner

$myfunction= ‘[bc_user_groups amount=”20″]’; $myfunction_parsed = do_shortcode($myfunction); became $atts = array( ‘amount’ => 20 ); $myfunction_parsed = bc_user_groups( $atts ); Call the shortcode function (I asume your shortcode function name is ‘bc_user_groups’) direct.

Numbering Image List in Gallery

Set a custom function between the gallery shortcode handler and the output. Catch the img elements and add a static counter. Then return the gallery output to WordPress. Sample code: add_action( ‘after_setup_theme’, ‘wpse_74492_replace_gallery_shortcode’ ); /** * Replace the default shortcode handlers. * * @return void */ function wpse_74492_replace_gallery_shortcode() { remove_shortcode( ‘gallery’ ); add_shortcode( ‘gallery’, ‘wpse_74492_gallery_shortcode’ … 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