Utilizing the theme.json file for customizing your WordPress site is a powerful way to enhance the user experience for those managing content within Gutenberg. We can access these settings within our custom gutenberg blocks by utilizing the “useSetting” function available within “@wordpress/block-editor”. Below is an example of how to utilize the color palette defined in […]
Code Snippets
Sharing our WordPress and Genesis code snippets.
Regex Redirect Rule to Remove Blog from Post URL but Keep Pagination
This is a common site migration redirection issue. We want to change the WordPress blog posts from having .com/blog/post-name-here/ in the URL to the single post URL being just .com/post-name-here/ But we often still have a .com/blog/ landing page AND it is often still paginated like .com/blog/page/2/ So the challenge is creating a 301 Redirect […]
Using WP-CLI to search-replace and Remove .html from End of URLs
Scenario: we were migrating a WordPress site from one domain to another. The blog posts all ended in .html which we wanted to remove for cleanliness and SEO. We created this code in WPENGINE to handle the redirects for any links to the old content: Domain: the URL of the old domain Source: ^(.+)\.html$ Destination: […]
Making a Redirect Work with Capitalization on WPENGINE
A client recently wanted to have a vanity URL redirect created. I had created one like https://limecuda.com/awesome-wordpress-hosting/ However, they wanted to have a URL like https://limecuda.com/Awesome-Wordpress-Hosting/ Here is how we accomplished accommodating uppercase letters using a bit of RegEx magic… Source: ^/[aA]wesome-[wW]ord[pP]ress-[hH]osting/?$ Destination: https://limecuda.com/services/hosting/ Boom. That is how you can accommodate a client who may […]
Updating A WordPress User Password – MySQL
When setting up new versions of live sites on your local machine, it’s easiest to migrate the entire database and dump it into your new install. We love using WP Migrate DB for this task. For local sites though, I like to have a very basic admin / password configured… Literally “admin” and “password”. In the […]
“Switch To User” Link on WooCommerce Order Details
The User Switching plugin is a great way to quickly see how Users at different access levels will interact with your site. It’s a necessary plugin for most development environments. (it also fits into our guidelines for extending WordPress for enterprise use) However, it can also be a great plugin for site admins working on […]
WordPress Conditional: “has_body_class()”
Was recently working on a new post layout for a site that we’re wanting to do some A/B testing for before shipping out the feature for the entire backlog of posts. Once we implement, there may be a few posts that keep the old layout which we’ll be controlling by giving those posts a certain […]
WPENGINE’s Common Plugin Error Code Showing up on the Front End
Just posting a quick fix in case others bump into this or we need to fix a site again 🙂 We had a strange case of the below code showing up on a front end page of a WPENGINE site… /wp-content/mu-plugins/wpengine-common/plugin.php on line 264 I tried using Perm-Reload-Apply but that did nothing. The strange part is […]
Filter Genesis Post Info for Post Types Without an Author
Problem Genesis Post Info is the information about the post (post date, author, comments) that typically displays just below the title on your posts. If you have a Post Type that doesn’t support an “Author” for the post, the post info will display the “by” component followed by an empty block. Solution Check the current […]
Force All set_url_scheme URLs to ‘https’
This was another fix that we needed to pursue when working with a site using a reverse proxy with WordPress. The problem occurs since the originating site for the reverse proxy cannot be secured with an SSL. The final site will be secured with an SSL but all the functions that use the “is_ssl()” conditional for generating […]
WordPress Reverse Proxy Conditional
We’ve got a WordPress project that is setup to run through a reverse proxy. With this setup, we constantly have situations where we need to check whether or not we’re accessing the site from its primary URL or via the reverse proxy. To do this, we set up a simple conditional to check the header for […]
Changing Custom Post Type Arguments
Many plugins register their own Custom Post Types (CPTs) for managing the content they’re adding to your site. However, there are times when you may want to change the default behavior of the post type. How do you change the arguments for creating the post type without manually changing the code in the plugin? Enter the […]
How to Increase the “Maximum Upload File Size” Limit in WPENGINE
We needed to up the “Maximum upload file size” limit on a client’s WordPress site hosted on WPENGINE. It starts at 50mb by default but we had media (audio) files that were often a bit more than that. We decided to raise the limit to 75 MB. This can be accomplished by adding this to […]
Make Yoast SEO’s Social Contact Methods Accessible on the Front-End of WordPress
The Yoast SEO plugin registers some helpful Social Media contact methods on a WordPress User Profile that are available for users to add information for Google+, Twitter, and Facebook. You can access the values set for each user on the front-end of your WordPress site using the get_the_author_meta() function. However, when creating an Author template in a […]
Ultimate Checklist for Migrating a WordPress Website to HTTPS / SSL
Need a comprehensive checklist to follow when migrating a WordPress site to use HTTPS? The below is the list our WordPress agency uses to make sure our SSL / TLS migrations go smoothly and nothing gets missed. If you want the nitty-gritty we also have a full guide to Properly Migrate a WordPress Website to HTTPS (SSL […]
Include Additional Contact Methods on WordPress User Profiles
On your WordPress user profile, you’ll notice that WordPress includes “Contact Info” fields to store: Email Website Google+ Twitter & Facebook information However, you can filter those contact methods to also include any other contact methods that you’d like. For example, the snippet below is what we’re using on this site to also include links to […]
Subdirectory and Following Pages Global Redirect on WPENGINE
Here is a good way to globally redirect a subdirectory and anything that follows to a final destination. originasite.com/first-folder/other-folder/slug-here/ originasite.com/first-folder/other-folder/other-slug-here/ would be redirected to finalsite.com/new-location/ Source: ^/first-folder/other-folder/.+ Destination: https://www.finalsite.com/new-location/ Carryover the Path If you want to preserve the part you are redirecting and it go to an equivalent page you would use: Source: ^/first-folder/other-folder/(.+) Destination: https://www.finalsite.com/new-location/$1 […]
How to See Facebook Share Counts for a Specific Post / Page
Ever wanted to see what the actual share count is for a URL? This trick is handy for troubleshooting share plugins (*ahem* MashShare) or even doing some competitive research. All you need to do is form and access this URL: http://graph.facebook.com/?id=URL_HERE See for instance, this URL for a client post: http://graph.facebook.com/?id=http://blog.joemcnally.com/2016/10/13/royal-photographic-society/ Returns a share count of […]