How to Show Different Themes to Logged in Users in WordPress - How to Show Different Themes to Logged-in Users in WordPress

How to Show Different Themes to Logged-in Users in WordPress

In this example, we’ll use the is_user_logged_in() to display a different theme on our website for visitors: if(is_user_logged_in()) { function wpxss_set_my_custom_theme() { //replace your theme name here return ‘your-theme-name’; } add_filter( ‘template’, ‘wpxss_set_my_custom_theme’ ); add_filter( ‘stylesheet’, ‘wpxss_set_my_custom_theme’ ); } else { // leave the default theme active for visitors } The template and stylesheet filters are responsible to select the activated … Read more

How to get free WordPress hosting - How to get free WordPress hosting?

How to get free WordPress hosting?

Back in 2010 when I was starting my web development journey, having a website was expensive, especially on a high-school student budget. I had plenty of dumb ideas, and no money to realize all of them (thank God 🙏). So I was looking for shortcuts to save on a domain name and hosting. I will … Read more

Display the total number of WooCommerce products - Display the total number of WooCommerce products

Display the total number of WooCommerce products

To display the total number of WooCommerce products, you can use the following code snippet: <?php $products = wc_get_products(array( ‘limit’ => -1 )); echo count($products); ?> This code uses the wc_get_products() function to retrieve all published products, with no limit on the number of products returned. The count() function is then used to count the … Read more

Reinstall WordPress Core using WP CLI - Reinstall WordPress Core using WP-CLI

Reinstall WordPress Core using WP-CLI

Useful WP-CLI commands that I use when cleaning hacked WordPress websites in order to reinstall WP core, all themes, and plugins from WordPress.org

WordPress Plugin and Theme Code Refactoring - WordPress Plugin and Theme Code Refactoring

WordPress Plugin and Theme Code Refactoring

Code refactoring is the process of restructuring existing code without changing its behavior. This is often done to improve the readability, maintainability, and performance of the code. In the context of WordPress plugins and themes, code refactoring might involve reorganizing code into smaller functions, renaming variables and functions to be more descriptive, or simplifying complex … Read more

Hide your WordPress site from Google and other Search Engines - Hide your WordPress site from Google and other Search Engines

Hide your WordPress site from Google and other Search Engines

If you want to hide your WordPress site from search engines, you can use the “Discourage search engines from indexing this site” option in the “Reading Settings” page of your WordPress dashboard. To access this option, follow these steps: This will add a “noindex” directive to your site’s pages, which tells search engines not to … Read more

Uncaught Error Call to undefined function wp in wp blog header.php16 - Uncaught Error: Call to undefined function wp() in wp-blog-header.php:16

Uncaught Error: Call to undefined function wp() in wp-blog-header.php:16

[20-Feb-2023 11:21:11 Europe/Belgrade] PHP Fatal error: Uncaught Error: Call to undefined function wp() in /home/user/example.com/wp-blog-header.php:16 Stack trace: #0 /home/user/example.com/index.php(17): require() #1 {main} thrown in /home/user/example.com/wp-blog-header.php on line 16 You may notice this error Uncaught Error: Call to undefined function wp() in wp-blog-header.php:16 on your error_log file if: wp() is a WordPress core function that calls … Read more