In the members-only forum, a user wanted to know how to automatically add slugs of both categories and tags to the existing list of body element’s classes in WordPress. Adding the following in child theme’s functions.php will automatically add categories and tags as body classes in WordPress on single pages (other than static Pages). To […]
Code Snippets
How to remove Scripts section from Pages of a specific Page Template in Genesis
In the comments section of The Comprehensive Guide to Genesis Theme Supports, a user asked: how can I remove the inpost scripts for a certain page template? Adding the following in child theme’s functions.php will make Scripts section to not appear for static Pages to which page_products.php template has been applied. add_action( ‘init’, ‘custom_remove_scripts’, 11 […]
How to wrap posts list in a container and reposition archive pagination on archives in Genesis
In GenesisWP Slack chat, a user asked: I’ve been searching for a simple way to do this and am stumped. In a CPT archive page Iād like to create a wrapper div around only the looped posts and not include the pagination, of the form; <main class=”content” id=”genesis-content”> <div id=”my-wrapper”> <article>…</article> looped etc … </div> […]
How to set Taxonomy Title and Description to appear only on the first page in Genesis
In GenesisWP Facebook group a user asked: I have been googling for a couple of days and checked the forums, but no help that I could find. I have a question. Is it possible to add a shortcode to make the Archive Intro Text appear only on the first page of the category archive? Title […]
How to allow oEmbed parsing in MemberPress excerpts
MemberPress is my plugin of choice for memberships and is what I use on this site. In your MemberPress settings, if you have set an excerpt to appear for unauthorized visitors, YouTube video URLs and links to tweets will appear as is and will not get parsed by WordPress’ oEmbed unless the following is added: […]
How to add custom attribute to a nav menu item in WordPress
Want to add a custom attribute like target=”foobox” or data-featherlight=”#enews-popup” to a specific nav menu item’s anchor? nav_menu_link_attributes filter hook in WordPress is your friend. For example, adding /** * Add custom attribute and value to a nav menu item’s anchor. * * @author Sridhar Katakam * @link https://sridharkatakam.com/ */ add_filter( ‘nav_menu_link_attributes’, function ( $atts, […]
How to add File Size admin column in WordPress Media Library
Looking to add file size column in the WordPress media library? Add the following in child theme’s functions.php: If you would like to use a plugin for the same, here are a few options: Media Files Tools Admin Columns References: http://wordpress.stackexchange.com/a/195842/14380 https://codex.wordpress.org/Function_Reference/size_format
How to add a URL admin column in WordPress Media Library
Update on February 12, 2017: Created a Plugin version of this. See near the end of this post. Wouldn’t it be handy to be able to easily copy a media item URL directly on the main Media Library screen rather than having to open the item? The following is better formatted version of this code […]
How to add a Time admin column in WordPress Media Library
Looking to display the time at which media has been attached/uploaded to your WordPress library along with the date? Add the following in your child theme’s functions.php: add_filter( ‘manage_media_columns’, ‘sk_media_columns_time’ ); /** * Filter the Media list table columns to add a Time column. * * @param array $posts_columns Existing array of columns displayed in […]
How to display different number of Posts in different views in WordPress
In Genesis Facebook group a user wants to know how 18 posts can be shown on search and category archives 6 posts can be shown on the first page of Posts page with the default number of posts as set in Settings > Reading appearing in all other views incl. the paginated pages of the […]
Recent Comments