Tips & Tricks

Disable WordPress Comments via Theme / functions.php

August 20, 2019 | Comments Off on Disable WordPress Comments via Theme / functions.php

Using Beaver Builder or Elementor and finding spam comments on attachments and other pages / post despite not using comments on the website? Insert the following code into your child theme’s function.php file. [php] <?php // Add to existing function.php file // Disable support for comments and trackbacks in post types function df_disable_comments_post_types_support() { $post_types […]

Read More

Disable Author pages in your WordPress installation

October 23, 2018 | Comments Off on Disable Author pages in your WordPress installation

If you don’t need author post pages in WordPress disable the link and have them redirect back to the homepage. Add the below code to your themes child function.php file. [php] add_action(‘template_redirect’, ‘my_custom_disable_author_page’); function my_custom_disable_author_page() { global $wp_query; if( is_category() || is_tag() || is_date() || is_author() ) { $wp_query->set_301(); status_header(301); // Redirect to homepage wp_redirect(get_option(‘home’)); […]

Read More

How to correctly load JavaScript / jQuery into WordPress

October 23, 2018 | Comments Off on How to correctly load JavaScript / jQuery into WordPress

Below is the correct way to load JavaScript / jQuery into your WordPress Website. Place the below custom code into your themes child function.php file. Just to note “custom.js” is the file we load from the theme folder. [php] // ADD CUSTOM JS function wpb_adding_scripts() { wp_register_script(‘my_amazing_script’, get_stylesheet_directory_uri() . ‘/custom.js’, array(‘jquery’),’1.1′, true); wp_enqueue_script(‘my_amazing_script’); } add_action( […]

Read More

Redirect WooCommerce Shop URL to HomePage

October 23, 2018 | Comments Off on Redirect WooCommerce Shop URL to HomePage

If your not using the “shop” page in your WooCommerce store, add the following your theme’s child function.php file. This code will redirect when you should land on the “shop” page back to the “Home Page” (root). This will change the link on the “Continue Shopping” button. [php] // REDIRECT SHOP URL TO HOMEPAGE add_filter( […]

Read More

Force www and https (ssl) in website URL via .htaccess

October 23, 2018 | Comments Off on Force www and https (ssl) in website URL via .htaccess

Having difficulty getting both https (SSL) and www to display in the website URL? Insert the below code into the .htaccess file in the root folder of your website. Obviously this requires both and SSL cert to be installed and working correctly, and also that both the www and non www version of your domain […]

Read More

Force an attachment to download

October 23, 2018 | Comments Off on Force an attachment to download

Here’s something I found out today, instead of messing around with .htaccess configurations to force a file to download instead of show in the browser, you can simply add the “download” tag to the HTML Anchor link. [html] <a href="myfile.pdf" download>Click to Download</a> [/html] Might save you some time / hassle trying to configure downloading […]

Read More