Tips

Use show_in_rest to enable Gutenberg block editor on custom post types.

Read More

Common 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 More

Works in single and page templates. Add at the top of the file.

<?php
/*
Template Name: Full-width page layout
Template Post Type: post, page, custom-post-type
*/

Source.

Read More

By default Shopify points to the /accounts page when Customers login. This function will redirect them to a page of your choice.

Read More

In 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 More

If all subscriptions have the same term (e.g. 1 year), this can help adjust the wording to something more specific.

Read More

Easily change the Sign-up Fee wording associated with WooCommerce Subscriptions.

Read More

For shops with very few Products.

Read More

Setup a stylesheet for the default login screen, and update the heading url.

Read More

Membership Site Edits

WordPress

February 02, 2022

Membership 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 More

This will search Posts and Post Types for Taxonomies that match the search terms and will return the Posts (not the taxonomies).

Read More

Works with Gutenberg.

Read More

Handy 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 More

Searching for SKUs returns no results by default. This function fixes this issue.

Read More

Last Item in Array

php

December 08, 2021

Useful to add custom styles or punctuation to last item in an array.

Read More

Previously examples of this that I’ve found and used don’t always seem to work. I found an updated version that works well.

Read More

This affects all post types. Wrap in conditions to reduce appearance. Featured Image column will appear last.

Read More

Use to convert text with spaces into lowercase data with dashes so it can be used for element tags.

Read More

Weekday Countdown

php

October 20, 2021

Worked on a subscription service website recently that had specific weekly cutoffs for ordering in order to have ordering available for the following week.

Read More

If Term is Parent Condition

php

September 22, 2021

Check if the current term is a parent and allow for different formatting based on conditions.

Read More

Help 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 More

Two 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 More

Use this in your theme’s stylesheet to customize the loading gif shown when Woocommerce Cart, Products, and Checkout are loading.

Read More

Place this in functions in order to create your own custom block styles and render them in the editor.

Read More

Working 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 More

In 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 More

How to remove the UL and Div containers on the wp_nav_menu() function.

Read More

Compatibility 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 More

I 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 More

Great for repeating content columns, where additional information appears inbetween rows on click.

Read More

Page Depth Condition

php

December 09, 2020

Comes in handy working with breadcrumbs, and sub-pages showing parent’s title.

Read More

I needed to display reviews from the Reviews page on a few select Pages and Products in a Shopify theme.

Read More

Alphabetized Glossary

php

October 07, 2020

Sort post content alphabetically, and divide each letter section with the appropriate letter.

Read More

The 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');
}

Source.

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 More

Simple function to check is WooCommerce Product is virtual. Can be used in the Cart or on Product page.

Read More

Ran 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 More

I use Page Links To a lot. Probably on every website I’ve built for the last five years.

Read More

If 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 More

Handy snippet for updating the default title text on a Comment Form.

Read More

When 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 More

Disable the default from WordPress version 5.4 that forces fullscreen mode as the default view in Posts, and Pages.

Read More

I used this on a custom page template showing only Past Events.

Read More

A 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 More

Need 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 More

Ideal for working with plugins where the fields are not available for editing / customization.

Read More

I 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 More

Disable Tabs

php

April 15, 2020

Remove Tabs from the sidebar, admin columns, and Post.

Read More

When a user is added to WordPress, their insert image settings have Link To Media set as the default option.

Read More

I’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 More

This comes in handy if the ecommerce store does not ship any physical materials (e.g., downloadable, e-tickets, online classes, membership, etc).

Read More

I 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 More

I really enjoyed customizing this. Check out more from the author of this snippet at the link below.

Read More

The below is used to check between two date fields and display only the items that fall within that parameter.

Read More

Count Divs with jQuery

jQuery

December 25, 2019

I’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 More

Style images differently according to weather the image is landscape, portrait, or even square.

Read More

This also works with Post Types created by Plugins.

Read More

These are some of the functions I use in my custom themes to setup my own defaults in Gutenberg.

Read More

If files within /woocommerce are being ignored, add support for Woocommerce as follows:

Read More

Place the below in your functions.php to add your own custom font options to the core Paragraph Block.

Read More

Brute 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 More

The Google Font Library is a great resource for free fonts.

Read More

Working 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 More

To 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 More

YouTube recently disabled the rel=0 option for disabling the trailing thumbnails at the end of videos.

Read More

Building 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 More

Thank 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 More

If 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 More

Want 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 More

Password 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 More

Working 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 More

Press play on the video when the slider loads to address the issue.

jQuery('#banner').on('init', function(ev, el){
jQuery('.videoWrapper').each(function () {
this.play();
});
});

Source.

Read More

Autosort data on a page from a hash URL using the following snippet and related HTML.

Read More

Most 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 More

Restrict access to backend based on user role:

Read More

Working with fixed headers and absolute-positioned drop-down menus can be difficult to adjust with CSS alone.

Read More

WordPress 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 More

Add 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 More

Place 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 More

I used this recently coupled with breadcrumbs to prevent certain items from showing on the top-most items in page hierarchy.

Read More

Works great if you’re using a sub-menu that shows related-level items when on a page.

Read More

When 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 More

Use the following snippet to return the Featured (starred) Products from the WooCommerce Product listing.

Read More

SVGs, when resized, will not scale in proportion in older versions of Internet Explorer.

Read More

Slick Slider has pause and play functions available, but they are not easily enabled. 

Read More

If you need to add Tags to your Custom Post Type, use the following snippet.

Read More

If you’ve run into an error where your site is loading all of your Pages as Blog or Archive.

Read More

Great to use on product pages to reveal varied standardized text from the template when Products use shared terms like colours, or sizes.

Read More

When 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 More

iOS Hover Events Fix

jQuery

February 13, 2019

iOS 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 More

Fonts will render differently across browsers, and sometimes even when different colours and background are being used.

Read More

Displaying 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 More

I’ve always wanted to apply automatic inherited styles to pages that are child pages of a custom template, and now I can!

Read More

Simple jQuery function to toggle between multiple containers on click.Filter links HTML:

Read More
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.