by Molly Roberts | Jan 2, 2023 | Code Snippets
You can use this code to find the absolute parent for any page: // Get the current page object $page = get_queried_object(); // Check if the current page has a parent if ( $page->post_parent ) { // Set the parent ID to the current page’s parent ID $parent_id =...
by Molly Roberts | Jan 1, 2023 | Code Snippets
Do you want to automatically add a signature to all comments created by WordPress administrators? It’s really easy. Place this code in your theme’s functions.php file or create a custom plugin with this code: /** * Custom function to automatically add a...
by Molly Roberts | Dec 31, 2022 | Code Snippets
Do you want to add additional fields to the comment form on your WordPress website? This will allow you to store additional data about your commenters. Place this code in your theme’s functions.php file or create a custom plugin with this code: /** * Custom...
by Molly Roberts | Dec 30, 2022 | Code Snippets
Do you want to allow your users to use shortcodes in their comments? There’s an easy way to do this. Warning: Allowing shortcodes in your WordPress comments can be a security hazard. Don’t use the below code unless you know what you’re doing. Place...
by mohitgangrade | Dec 30, 2022 | Code Snippets
Do you want to stop storing the IP Addresses of your website users who leave comments? Here’s the code you need. Place it in your WordPress theme’s functions.php file: /** * Custom function to stop storing IP addresses in WordPress comments * * @param...
by Molly Roberts | Dec 30, 2022 | Code Snippets
Today, I’ll show you how to remove CSS classes from Post Thumbnails in WordPress posts. It’s really simple and only requires adding code to your WordPress website. Place this code in your theme’s functions.php file or create a custom plugin with this...
by Molly Roberts | Dec 30, 2022 | Code Snippets
Do you want to limit the number of CSS classes the post_class function outputs when called? This will limit the number of CSS classes WordPress adds to a post. Place this code in your theme’s functions.php file or create a custom plugin with this code: /** *...
by Molly Roberts | Dec 30, 2022 | Code Snippets
Do you want to add a class to the tag in WordPress based on what browser and operating system a visitor uses?Adding a class called Windows or macOS to the body tag allows you to add styles to your website that are only shown to those operating systems. You can also...
by Molly Roberts | Dec 28, 2022 | Code Snippets
If you’re a WordPress user looking to give your posts and pages a unique touch, you’ve come to the right place! This article will explain the importance and benefits of custom CSS and how to add it to specific posts and pages within WordPress. Adding...
by Molly Roberts | Dec 27, 2022 | Code Snippets
When you want to add custom styling to your WordPress website, you may want to add a CSS class to the body tag. This is a great way to easily apply a group of styles to all posts and pages. This article will show you exactly how to add a CSS class to your body tag...