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.

Pagination in a Shortcode. Get_next_posts_link not working but get_previous_posts_link works fine right next to it

This is an old question, but I needed the answer to this one as well. Here is the solution taken right from the WP codex… $prev = ‘<div class=”nav-previous”>’ . get_next_posts_link( __( ‘<span class=”meta-nav”>&larr;</span> Previous’ ), $loop->max_num_pages ); You need to append the max_num_pages parameter from the query to your output and it should work … Read more

echo do_shortcode is not working on theme’s template

According to the developer of the jwPlayer it was necessary to implement the plugin as a filter to be able to support ‘.’ in tag attributes. Hence do_shortcode(..) does not work but jwplayer_tag_callback(..) will return the desired result. Matching your example simply execute: echo jwplayer_tag_callback(‘[jwplayer config=”Out-of-the-Box” file=”‘ . $urlbox[0] . ‘” image=”http://www.mywebsite.com/myimage.jpg”]’);

Frontend editing, Frontend user dashboard

I have Something that i use from time to time when i need something like that: <?php /* Plugin Name: List User Posts Plugin URI: http://en.bainternet.info Description: lists user posts on the front end Version: 0.1 Author: Bainternet Author URI: http://en.bainternet.info */ if (!class_exists(‘list_user_posts’)){ /** * list_user_posts * @author Ohad Raz */ class list_user_posts { … Read more

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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)