In my last tutorial I wanted to output a nav menu assigned to a particular theme location with the nav element having the standard auto generated class as well as a custom one. wp_nav_menu( array( ‘theme_location’ => ‘header’, ‘divider_html’ => $divider_html, ‘container’ => ‘nav’, ‘menu_class’ => ‘menu genesis-nav-menu menu-header js-superfish’ ) ); outputs for example, […]
Code Snippets
How to automatically add first, last and numbered classes to widgets in WordPress
While it is possible to add several useful widget classes using a plugin like Widget CSS Classes in this post I share the code found in wordpress.org forum post to automatically add widget-first, widget-last and numbered classes (widget-1, widget-2 etc.) to widgets in all widget areas. Before: After: Add the following in child theme’s functions.php: […]
Useful functions for checking Pages and their sub Pages in WordPress
To check a Page by ID for that Page or its direct descendants (sub/child pages) Usage: if ( is_tree( 645 ) ) {} or to check by ID or slug or title: Usage: if ( is_child( 645 ) ) {} or if ( is_child( ‘Services’ ) ) {} or if ( is_child( ‘our-services’ ) ) […]
Displaying a fixed number of posts in WordPress without Pagination
Scenario: Settings > Reading set to show 10 (or whatever number, doesn’t matter) latest blog posts (WordPress default). And you want to display just 3 Posts without links to next sets of paginated pages. So let’s just add this in functions.php: Simple, right? Apparently, that is not sufficient. When you reload your Posts page (the […]
How to apply body class in WordPress conditionally for a Page and all its sub Pages
In the members-only forum a user asked: I want to style the h1.entry-title differently for each parent/child page. So About page, and all its sub pages would have a class .blue-bg, Events Page would have .green-bg, etc., with css as below. I have tried using is(tree) code with conditional body_class but it is not working. […]
How to use WordPress Customizer for setting up Background Image of a section in Genesis
Updated on August 27, 2016 In the comments section of How to use a full-width background image in Home Top widget area of Enterprise Pro tutorial, a user asked: This worked perfectly for me, but my client wants to be able to change the image at some point and she is not going to be […]
JetPack Related Posts Customizations
One of the many useful modules of JetPack is Related Posts. In this tutorial I share a few code snippets that I used in one of my recent site build with featured images set to appear via the plugin’s “Use a large and visually striking layout” setting. More here. Change the size of images This […]
Sublime Text Snippets for Genesis
Sublime Text is a fantastic cross-platform text/code editor that’s fast, lightweight, customizable and powerful. The same adjectives hold good for the Genesis WordPress framework. In the past Justin Tallant has created a Sublime Text package for Genesis that includes 24 snippets some of which have not been updated to account for the HTML5 update of […]
Comma separated taxonomy terms in WordPress
Want to display unlinked terms that the current entry has for a specific custom taxonomy within the loop? Here’s the sample code for that. Replace staff-position with your custom taxonomy. and the function call: Slightly different method: http://codex.wordpress.org/Function_Reference/get_the_terms#A_Basic_Example
Adding Categories support to a Custom Post Type in WordPress
When a CPT is manually created in WordPress using register_post_type function it can be linked to the built-in category taxonomy via When register_post_type() is defined without support for categories and is coming from a plugin that you can (should) not modify, it is still possible to add categories support to the CPT by adding the […]
Recent Comments