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, […]
Search Results for: wordpress
Genesis Sample’s Functions per WordPress PHP Documentation Standards
I’ve recently set up WPCS (WordPress Coding Standards) in my editor, Sublime Text and have since been diligently adding appropriate comment blocks for the various code I use/write, thanks to the linting or automatic code suggestions. Looking at the code in the current latest Genesis Sample 2.2.4’s functions.php, there are minor improvements that can be […]
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 set up a simple FAQ section in WordPress using jQuery Collapse
In the past, I showed how jQuery Collapse can be used to display ACF Pro Repeater fields in the form of an open/close or expand/collapse section in Genesis here. This tutorial provides the steps for showing a FAQ section from static HTML content using jQuery Collapse. Screenshots: with all the panels closed: with a panel […]
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 […]
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: […]
Changing the posts per page on first page without breaking pagination in WordPress
Each page (first and subsequent paginated pages) of Posts page in WordPress shows the same number of posts as set for “Blog pages show at most” setting. If you want to display a different number of posts on the first page this can be done by specifying posts_per_page for non/paginated page(s) in a function hooked […]
How to automatically add browser class to html in WordPress
Quoting MDN, Note: It’s worth re-iterating: it’s very rarely a good idea to use user agent sniffing. You can almost always find a better, more broadly compatible way to solve your problem! That out of the way there are certain situations where you need to have the browser name automatically added to html/body element in […]
Recent Comments