Remove the prepended ‘Category:’ or ‘Archive:’ when trying to echo the name of the archive in WordPress.
Category: WordPress
Loop through Taxonomies and list posts underneath
In my WordPress site, I had a need to list all taxonomies and underneath them, their related custom post types.
To do this, I used this code below. Obviously replace “custom_taxomy” with your taxonomy name and “custom_post_type” with your post type name.
Add inline JS to WordPress footer
Adding JS to WordPress can be done in two ways. The first way is to enqueue the JS file.
The second way can be done by adding inline JS via a hook in functions.php – this is most likely used to initialize a script that is enqueued or add Google Tracking codes, Facebook pixels etc.
Change excerpt size in WordPress
The default WordPress excerpt character length can be changed by inserting the below snippet into your functions.php.
Change 20 to however many characters you want to limit your excerpt to.
Read More
Remove Yoast SEO WordPress titles and descriptions in MySQL FAST
I needed to delete all custom titles and descriptions fast from Yoast plugin for WordPress.
To do it, I used these SQL queries in MySQL
Remove gravity forms unlicensed message
Gravity forms is a great forms plugin for WordPress. I purchased a licence and it lapsed, but I still use it on my website. The problem is, because the licence is lapsed, I am seeing an ugly, annoying message saying that my copy is unlicensed. Just to clarify, I did buy a licence, and I am allowed to use the copy, I just don’t want to renew it for a new version.
To remove the nag, it’s a bit tricky, Gravity Forms have gone above and beyond to make it difficult for people to do to protect their bottom line and just annoy someone to eventually re-licence.
However, with that being said, just add this to your functions.php file.
Styling WooCommerce Tabs
WooCommerce, an extension for WordPress makes it simple to sell online. What’s a bit painful though is overriding the styles if you’re creating your own theme.
Specifically the tabs, they are painful.
Here’s a small snipper to restyle the woocommerce tabs and take away that rounded look to them.
Manipulate the colours in this code as you see fit. Make sure you place the css after WooCommerce styling.
.woocommerce div.product .woocommerce-tabs ul.tabs li::before, .woocommerce div.product .woocommerce-tabs ul.tabs li::after, .woocommerce div.product .woocommerce-tabs ul.tabs::before { display:none; } .woocommerce div.product .woocommerce-tabs ul.tabs li{ border-radius:0; } .woocommerce div.product .woocommerce-tabs ul.tabs li.active { background:blue; color:#fff; } .woocommerce div.product .woocommerce-tabs ul.tabs li{ background:transparent; border:0; a { padding:1rem; } } .woocommerce div.product .woocommerce-tabs ul.tabs { padding:0; } .woocommerce div.product .woocommerce-tabs ul.tabs { border-bottom:1px solid #999 }
WordPress SMTP without any plugins
WordPress is a very good CMS, BUT! I hate plugin bloat. I’ve seen so many websites use a huge amount of plugins to cover every little feature, which contributes to speed issues and can cause problems down the track.
There are heaps of SMTP Plugins for WordPress available so that you can use AMAZON SES , SendGrid, MailGun, etc. The easiest way to set up SMTP is to add this snippet to your functions.php file, this will ensure that WordPress uses SMTP instead of the standard PHP Mail.
Add this to your functions.php file and configure how you need to. Then save it.
// USE SMTP add_action( 'phpmailer_init', 'setup_phpmailer_init' ); function setup_phpmailer_init( PHPMailer $phpmailer ) { $phpmailer->Host = 'HOSTNAME'; // eg. email-smtp.us-west-2.amazonaws.com $phpmailer->Port = 587; // could be different $phpmailer->Username = 'ENTERUSERNAME'; // SMTP Username $phpmailer->Password = 'ENTERPASSWORD'; // SMTP Password $phpmailer->SMTPAuth = true; // Set to true if login is required $phpmailer->SMTPSecure = 'tls'; // enable if required, 'tls' is another possible value $phpmailer->IsSMTP(); }
Hope that helps!
Simple WordPress User Restriction Tutorial without using Plugins
When you need to restrict users in WordPress, there are heaps of plugins you can download. Personally, I think too many plugins is a bad practice in WordPress, it can lead to “plugin bloat”, where your website can be slowed down and you’re reliant on too many plugins to make your site work.
In the video below, you will see how I manage user restrictions quite easily using a must use plugin in WordPress and a few minutes of my time.
Show list of taxonomy terms for a specific post in WordPress
Have you set up custom taxonomies in WordPress and want to display all of the terms that a post has on it’s single page? No problems, paste the below code into your template. Read More