How to Add Custom PHP Code to WordPress - How to Add Custom PHP Code to WordPress

How to Add Custom PHP Code to WordPress

In some cases, you may need to add a function to your WordPress website, either to hook something into the theme or use a filter to change something in the theme. One method of making changes to your site using code snippets is through the use of the theme functions.php file. To edit PHP files make sure … Read more

Add an Edit Post Link to WordPress Posts and Pages - Add an ✏️ “Edit Post” Link to WordPress Posts

Add an ✏️ “Edit Post” Link to WordPress Posts

This WordPress snippet will add an “edit page” link on the WordPress posts and pages. Only users who are logged in and have the necessary rights to edit that page will be able to see this link (administrator or author). Add the snippet to the theme page where you want the link to appear, for … Read more

How to delete all comments in WordPress - How to delete all comments in WordPress? 🗑️💬

How to delete all comments in WordPress? 🗑️💬

WordPress uses the wp_commentmeta and wp_comments tables to store comments and their data. To delete all comments in WordPress simply empty those tables in the database: To delete all spam comments use: To delete all unapproved comments use: NOTE: In the above commands change wp_ prefix with the table prefix that you are using *(view … Read more

Display the total number of posts in WordPress - Display the Total 🔢 Number of Posts in WordPress

Display the Total 🔢 Number of Posts in WordPress

Step 1. Add the following inside your theme functions.php file or create a new Child theme first and add the code to it: Step 2. Add the shortcode [total_posts] anywhere on the website where you want to display the total number of posts: And it will display the number. 🙂

before - How to add text before price in WooCommerce

How to add text before price in WooCommerce

To put a string before the price of WooCommerce product and cart pages, use the WooCommerce filters woocommerce_cart_item_price and woocommerce_get_price_html Add the following code to your active theme functions.php file. Make sure to change <span class=”price-prefix”>TEXT BEFORE THE PRICE</span> with your text or HTML code. NEXT: How to Add text after the price in WooCommerce