One of the features I recently finished for the my redesign of my JavaScript for WordPress site was to have users taken to a special page once they complete a course. You can do this a number of ways, but here is how I did it: 1. Setup Congratulations Pages for Each Course The first thing I did was … Continue reading How to Redirect to Custom Page After Completing a LearnDash Course
Tag: functions.php
How to Add Meta Descriptions to WordPress Themes Using functions.php
While working on an SEO for WordPress course recently, I was looking for a way to manually add meta descriptions to a theme from the functions.php file. After playing around a bit, I came up with this solution: https://gist.github.com/zgordon/950159056d2ad299b0ee This of course raises the bigger question of why would you want to do this instead of … Continue reading How to Add Meta Descriptions to WordPress Themes Using functions.php
How to Deregister, Unqueue and Unhook a Parent Theme CSS Stylesheet
There comes a time when working with a WordPress project where you want to not include certain CSS from a parent theme or plugin. For example, a parent theme may include extra stylesheets that you don't want or a plugin may be adding styles that conflict with your site. On a recent project, I wanted to remove … Continue reading How to Deregister, Unqueue and Unhook a Parent Theme CSS Stylesheet
How to Overwrite Child Theme Functions
Big shout out to Otto for his article on Child Themes. I was recently trying to overwrite parent theme functions and came across this article. Scroll down a bit to Overriding Functions to see how it's done.
How to Send Emails in WordPress from the Functions.php
I have been working on a project that needs to occasionally send off emails. If you need to do so, here's how with wp_mail(): add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); wp_mail('whoever@whatever.com', 'Subject', 'Message'); Thanks to WordPress Cheat Sheets for the code!
How to Load Conditional CSS The Right Way in WordPress
Big thanks to Micah Wood for his article showing how to load conditional stylesheets the right way via the functions.php file. Thanks Micah for the great post!
How to Change the Length of Excerpts in WordPress
Simple little function here for the next time you need to control how many characters the_excerpt tag shows. function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); Just add the code above into the functions.php file. You can read more about this on the Codex.
The Difference Between WordPress Filters and Actions
Thanks to Otto for making the difference between actions and filters clear: Filters filter things. Actions do not. And this is critically important when you’re writing a filter. A filter function should never, ever, have unexpected side effects. There, you go, pretty straightforward! He actually makes some really good, concise points about the difference between … Continue reading The Difference Between WordPress Filters and Actions
A function to use remove_action conditionally in your WordPress templates
Thanks to Jonathan Perez for this little function to use remove_action conditionally. Helped when I was working on a WooCommerce project.
Create a Function to Create WordPress Widgets
I've taken to the practice of doing something like this whenever I need to create multiple widgets in a theme that all have the same basic parameters. function create_widget($name, $id, $description) { register_sidebar(array( 'name' => __( $name ), 'id' => $id, 'description' => __( $description ), 'before_widget' => ' ', 'after_widget' => ' ', 'before_title' … Continue reading Create a Function to Create WordPress Widgets