Theming

Enable or Disable Automatic Updates of WordPress Core, Themes and Updates using Functions.php

Placing this in functions.php will enable automatic updates of the WordPress core, plugins and themes. /* configure automatic updates */ add_filter( ‘auto_update_core’, ‘__return_true’ ); add_filter( ‘auto_update_plugin’, ‘__return_true’ ); add_filter( ‘auto_update_theme’, ‘__return_true’ ); Changing __return_true to __return_false disables said updates. These can be further refined to limit the level of updates and include only certain plugins.…

Read More

Child Themes Done the Right Way using functions.php

Was a time when linking a child theme to the parent theme was done via an import in the style sheet. No more, now the best way to do this is via the functions.php file as follows: function my_theme_enqueue_styles() { $parent_style = ‘parent-style’; wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ ); wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array(…

Read More

Check for Featured Image and Display It With The Caption

First check for the existence of the image then display it in the content area: In the template us this: // check if the post has a Post Thumbnail assigned to it. if ( has_post_thumbnail() ) { the_post_thumbnail(); } This defaults to the Thumbnail size under Settings. Size can be set by adding sizing parameters…

Read More

Add Additional Menus to Child Theme

TwentyTwelve supports one menu and TwentyFourteen supports two but more can be added. These instructions apply to TwentyTwelve but can be adapted to TwentyFourteen. Child theme files: functions.php header.php js/navigation.js functions.php De-queue the original navigation.js script and queue the one in the child theme. // de-queue navigation js add_action(‘wp_print_scripts’,’tto_dequeue_navigation’); function tto_dequeue_navigation() { wp_dequeue_script( ‘twentytwelve-navigation’ );…

Read More

Change Single Page Navigation Text and Styling

In single.php replace: // Previous/next post navigation. twentyfourteen_post_nav(); ¬†with this: <nav class=”navigation post-navigation” role=”navigation”> <h1 class=”screen-reader-text”><?php _e( ‘Post navigation’, ‘twentyfourteen’ ); ?></h1> <div class=”nav-links”> <?php if ( is_attachment() ) : previous_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Published In</span>%title’, ‘twentyfourteen’ ) ); else : previous_post_link( ‘%link’, __( ‘<span class=”meta-nav”>&lt;&lt;Previous</span>%title’, ‘twentyfourteen’ ) ); next_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Next&gt;&gt;</span>%title’, ‘twentyfourteen’…

Read More

Hard Code Squelch Tabs

Hard code the Squelch tabs in a template so you can use scripts inside the tabs. Install Squelch Tabs and Accordians. Then in template: Title 0 Title 1 Title 2 Title 3 Content 0 Content 1 Content 2 Content 3

Read More

Load Custom JS Scripts

To load a custom js script when, for instance page ID 434 is loaded place the following in theme functions.php: // load our own validation script on page 434 add_action( ‘wp_enqueue_scripts’, ‘babelscribe_load_scripts’ ); function babelscribe_load_scripts() { // register your script location, dependencies and version wp_register_script(‘action_script’, get_stylesheet_directory_uri().’/js/actions.js’, array(‘jquery’)); // enqueue the script if (is_page(434)) { //…

Read More

Custom Widget Area

Register a Custom Sidebar as described here Add widget to the sidebar. Use the following in your template file to show the sidebar (custom widget area) // Custom widget Area Start if( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘Left Column Widgets’) ) : endif; // Custom widget Area end where ‘Left Column Widgets’ is the registered name of the…

Read More

Custom Admin Styles

In THEME/functions.php add: // Custom WordPress Styles function admin_css() { wp_enqueue_style( ‘admin_css’, get_stylesheet_directory_uri() . ‘/admin.css’ ); } add_action(‘admin_print_styles’, ‘admin_css’ ); Add your custom admin styles to THEME/admin.css

Read More