Use show_in_rest to enable Gutenberg block editor on custom post types.
Read MoreCommon issue on shared hosting. Debug is unable to be deactivated due to host settings.
Solution:
ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Read More
Particularly for use on the home page when design layouts do not include title text in the content area.
Read MoreBy default Shopify points to the /accounts page when Customers login. This function will redirect them to a page of your choice.
Read MoreIn the attached example, an each function is used to equalize the heights of the containers based on the width of the columns so the images will show in equal size.
This allows for the same type of element to be setup multiple ways without additional classes / css.
Read MoreIf all subscriptions have the same term (e.g. 1 year), this can help adjust the wording to something more specific.
Read MoreEasily change the Sign-up Fee wording associated with WooCommerce Subscriptions.
Read MoreFor shops with very few Products.
Read MoreSetup a stylesheet for the default login screen, and update the heading url.
Read MoreMembership type websites need to be customized to prevent Subscribers from accessing certain areas of WordPress core. After setting up a front-end Profile page or Dashboard, it is necessary to redirect to these areas for the appropriate user types.
Read MoreThis will search Posts and Post Types for Taxonomies that match the search terms and will return the Posts (not the taxonomies).
Read MoreWorks with Gutenberg.
Read MoreHandy if you’re using the default category as “All Products” and want to prevent unrelated items from appearing related when no other categories are selected.
Read MoreSearching for SKUs returns no results by default. This function fixes this issue.
Read MoreUseful to add custom styles or punctuation to last item in an array.
Read MorePreviously examples of this that I’ve found and used don’t always seem to work. I found an updated version that works well.
Read MoreThis affects all post types. Wrap in conditions to reduce appearance. Featured Image column will appear last.
Read MoreUse to convert text with spaces into lowercase data with dashes so it can be used for element tags.
Read MoreWorked on a subscription service website recently that had specific weekly cutoffs for ordering in order to have ordering available for the following week.
Read MoreCheck if the current term is a parent and allow for different formatting based on conditions.
Read MoreHelp visitors sort content on your website by adding filtering options to your Posts.
WP Popular Posts Plugin plugin used in the below example in order to add support for filtering Most Popular items (determined by number of views).
Read MoreTwo examples provided comparing the regular select and multi-select field functions for Gravity Forms.
Place in functions.php. Update filter number with the form ID.
Read MoreUse this in your theme’s stylesheet to customize the loading gif shown when Woocommerce Cart, Products, and Checkout are loading.
Read MorePlace this in functions in order to create your own custom block styles and render them in the editor.
Read MoreWorking on new layouts on a live site? Client unfamiliar with WordPress and how to login and view Draft pages?
Use this in your header file to generate private content links for review.
Read MoreIn the past I’ve manually changed the content of the jquery file (I know, bad bad bad), or used a plugin to make this editable for me (also, bad bad bad). This snippet helps avoid those two methods and lets the edit occur within your theme.
Read MoreHow to remove the UL and Div containers on the wp_nav_menu() function.
Read MoreCompatibility requests with older browsers are becoming less frequent, but we had another one recently, and I wanted to give it a try while still utilizing our favourite plugins.
Read MoreI recently built a website with a large featured banner on their home page, and events page. Banners information was held in a Custom Post Type, and Events were created by The Events Calendar plugin.
The client wanted to combine these two items to show all of the banners on the Home page, to more readily promote their events.
Read MoreGreat for repeating content columns, where additional information appears inbetween rows on click.
Read MoreComes in handy working with breadcrumbs, and sub-pages showing parent’s title.
Read MoreI needed to display reviews from the Reviews page on a few select Pages and Products in a Shopify theme.
Read MoreSort post content alphabetically, and divide each letter section with the appropriate letter.
Read MoreThe site health widget can alert you to issues on the website, but this can also be confusing to clients and increase maintenance requests to resolve “issues” when the website is functioning properly. Hide this widget using the following snippet.
Place in functions.php
add_action('wp_dashboard_setup', 'remove_site_health_dashboard_widget');
function remove_site_health_dashboard_widget()
{
remove_meta_box('dashboard_site_health', 'dashboard', 'normal');
}
Read More
Annual events (festivals, haunts, etc.) generally occur within the same month each year. Use this function to force update all of your calendar views so scheduled events are seen first without having to navigate through month / week views.
Read MoreSimple function to check is WooCommerce Product is virtual. Can be used in the Cart or on Product page.
Read MoreRan into an issue with an e-commerce Product quantity field where the up / down arrows would not show, and were required to indicate more than one item could be purchased.
Read MoreI use Page Links To a lot. Probably on every website I’ve built for the last five years.
Read MoreIf you’ve forgotten what email and password you used to setup a website (or entered your email wrong, or your website isn’t sending reset password links to you!), you can setup an admin user via FTP using the following function.
Read MoreHandy snippet for updating the default title text on a Comment Form.
Read MoreWhen content is set to Password Protected, the word “Protected” appears in front of the title in the content area within loops, and on single Post and Pages.
Read MoreDisable the default from WordPress version 5.4 that forces fullscreen mode as the default view in Posts, and Pages.
Read MoreI used this on a custom page template showing only Past Events.
Read MoreA fixed header can cause auto-scroll content to be covered. Use this function to offset the scroll to the height of the fixed container.
Read MoreNeed to add varied styles to rows, but don’t want to program it in the backend? Or add ID numbers to rows in order to setup toggles?
Read MoreIdeal for working with plugins where the fields are not available for editing / customization.
Read MoreI needed to query multiple post types and specific taxonomies and meta for a featured banner on a website, and found that using an array for post_type wasn’t working with the tax_query.
Read MoreRemove Tabs from the sidebar, admin columns, and Post.
Read MoreWhen a user is added to WordPress, their insert image settings have Link To Media set as the default option.
Read MoreI’ve seen a lot of suggestions online to copy the Logout link shown in the WordPress backend into a Custom Link when using wp_nav_menu().
However, this will redirect users to the Logout Confirmation screen, and they will be prompted to logout once more.
Read MoreThis comes in handy if the ecommerce store does not ship any physical materials (e.g., downloadable, e-tickets, online classes, membership, etc).
Read MoreI stumbled across this while creating a query of Custom Post data, where the content needed to be laid out in columns, and rows of equal height.
Read MoreI really enjoyed customizing this. Check out more from the author of this snippet at the link below.
Read MoreThe below is used to check between two date fields and display only the items that fall within that parameter.
Read MoreI’ve been working with a few plugins lately that have templates, but do not allow for editing for the loop, so I’ve been unable to add counters with PHP.
Read MoreStyle images differently according to weather the image is landscape, portrait, or even square.
Read MoreThis also works with Post Types created by Plugins.
Read MoreThese are some of the functions I use in my custom themes to setup my own defaults in Gutenberg.
Read MoreIf files within /woocommerce are being ignored, add support for Woocommerce as follows:
Read MorePlace the below in your functions.php to add your own custom font options to the core Paragraph Block.
Read MoreBrute Protect settings within JetPack add security against malicious login attempts. Occasionally, these settings can lock the login page completely, even with your IP address added to the whitelist.
Read MoreThe Google Font Library is a great resource for free fonts.
Read MoreWorking with Gutenberg, I’ve learned how to build custom blocks to show content inline on a page, but I thought there could be an easier way that building a block, or a custom template.
Read MoreTo add a Custom Post Type to the Appearance > Menus section of the backend, add show_in_nav_menus => true to the Post Type args.
Read MoreYouTube recently disabled the rel=0 option for disabling the trailing thumbnails at the end of videos.
Read MoreBuilding a custom website for a client or a friend, it might be easier to setup the site / brand colours as the defaults available in the Colour Settings dropdown.
Read MoreThank you so much to Chittaranjan for posting this on Stackexchange…
This function targets wp_nav_menu by it’s theme_location, and dynamically adds a Login / Logout button to it, including nonce.
Read MoreIf you’re inundated with blocks that are not being used in your Theme template, and you would would like to hide unused blocks; use the default settings within WordPress core to remove the blocks from the “Add Blocks” option.
Read MoreWant to hide the editor from the WordPress editor because:
- there are several users accessing the WordPress backend
- a client has requested this feature be disabled
- you never user it
Add the following line to wp-config.php above the “That’s it, happy blogging” comment line.
define('DISALLOW_FILE_EDIT', true );Read More
Plugins, and Custom Post Types can add to your search results, and this isn’t always easy to adjust. You can edit your Post Type settings to exclude from search, but sometimes you need these items searchable in some areas of your website (like a directory), but not in the general search.
Read MorePassword Protected items show up in Search Results for logged in Users. This can be confusing when linking to those items for users without accounts.
Read MoreWorking on client websites with installed plugins, use the below information to update labels in the backend sidebar so the updating information is easier to find.
Read MoreAutosort data on a page from a hash URL using the following snippet and related HTML.
Read MoreMost of the examples for this that I have seen were for adding images to the column area, and did not explain how to fix column content brought in by custom post types.
Read MoreRestrict access to backend based on user role:
Read MoreWorking with fixed headers and absolute-positioned drop-down menus can be difficult to adjust with CSS alone.
Read MoreWordPress supports a bunch of different file types already, but working within different industries, and creating online databases / libraries for clients requires the need for the addition of file types that are not supported by WordPress.
Read MoreAdd show_in_rest => true to the array for the custom post type to enable the gutenberg editor, and to the taxonomy to have the item appear in the Gutenberg editor’s sidebar.
Read MorePlace the below snippet in wp-config.php to prevent your WordPress install from prompting for the username and password for FTP when performing updates.
Read MoreI used this recently coupled with breadcrumbs to prevent certain items from showing on the top-most items in page hierarchy.
Read MoreWorks great if you’re using a sub-menu that shows related-level items when on a page.
Read MoreWhen adding content, sometimes it’s necessary to add in extra non-breaking spaces to adjust spacing on desktop. Even some plugins (Shortcodes Ultimate) will create additional paragraph tags in the content area that cannot be removed from the editor.
Read MoreUse the following snippet to return the Featured (starred) Products from the WooCommerce Product listing.
Read MoreSVGs, when resized, will not scale in proportion in older versions of Internet Explorer.
Read MoreSlick Slider has pause and play functions available, but they are not easily enabled.
Read MoreIf you need to add Tags to your Custom Post Type, use the following snippet.
Read MoreIf you’ve run into an error where your site is loading all of your Pages as Blog or Archive.
Read MoreGreat to use on product pages to reveal varied standardized text from the template when Products use shared terms like colours, or sizes.
Read MoreWhen using Variable Products in WooCommerce, the default “Choose an option” text is pretty boring. You can use a function to customize it to match your specific offered Products.
Read MoreiOS devices when programmed to use “hover” with css will often ignore this effect in handheld and touchscreen devices, forcing the user to double-click in order to reveal toggled or hidden content.
Read MoreFonts will render differently across browsers, and sometimes even when different colours and background are being used.
Read MoreDisplaying an image from an ACF custom field is slightly different on an Archive / Single page, versus on a page, or in a regular loop.
Read MoreI’ve always wanted to apply automatic inherited styles to pages that are child pages of a custom template, and now I can!
Read MoreSimple jQuery function to toggle between multiple containers on click.Filter links HTML:
Read More