Wednesday 12 February 2014

How to Enqueue javascript/jQuery in theme footer with wp_enqueue_script

You can simple enqueue theme .js files in the wp_enqueue_script function in functions.php but what if you want to enque a block of javascript code or jQuery code in the footer of the theme.

One solution is to hard code the code in the footer by including opening and closing tags of script but if your are a theme designer you can have error by your theme reviewer or theme check plugin that one hard coded javascript or jQuery block of code found in footer.php the the following solution will work perfectly

go to your favorite editor and create a new custom-functions.js file paste the block of code and save the file with extension .js this will create a new jQuery file (custom-functions.js) in your theme /js directory now you can simply enqueue the  .js file with wp_enqueue_script function.


/*register and enque theme scripts and styles*/ 
add_action( 'wp_enqueue_scripts', 'oopthemes_scripts_styles' );
function oopthemes_scripts_styles() {
    // Custom jQuery Functions
    wp_enqueue_script( 'custom-functions', get_template_directory_uri() . '/js/custom-functions.js', array(), '1.0', true );
}

Share and Comment your idea or problem regarding wp_enqueue_script

Tuesday 11 February 2014

Condition for plugin active - is_plugin_active

condition check for plugin if is active plugin wordpress
Condition check for plugin - is_plugin_active

Recently When I was creating a theme for wordpress using Bootstrap 3. I decided to add bootstrap CPT Carousel plugin.

When I added the shortcode in the homepage it worked properly but when plugin is not active it prints the short code [image-carousel"] on the homepage.

The solution I found was checking if the plugin is active or not.

Saturday 8 February 2014

Recent Posts with Thumbnail - WordPress Bootstrap Widget

Recently I have created a Widget for my WordPress.org theme "Gule". you can download the theme Gule. It shows the latest post with featured image and meta information about the recent post. It is a bootstrap based theme so the widget only work well in styling for bootstrap themes.

recent_posts_with_thumbnail_widget_custom_bootstrap_3_wordpress
WordPress Bootstrap Custom Widget - Recent Posts With Thumbnail