WP Beaches https://wpbeaches.com Websites on the Northern Beaches Sat, 23 Nov 2019 03:07:42 +0000 en-US hourly 1 https://wordpress.org/?v=5.3.2 https://wpbeaches.com/wp-content/uploads/2017/08/cropped-wpb-site-icon-90x90.png WP Beaches https://wpbeaches.com 32 32 78264140 Set up WordPress wp-cron.php to run via real cron in cPanel, Cloudways and with Caching https://wpbeaches.com/set-up-wordpress-wp-cron-php-to-run-manually/ https://wpbeaches.com/set-up-wordpress-wp-cron-php-to-run-manually/#respond Fri, 22 Nov 2019 05:38:48 +0000 https://wpbeaches.com/?p=16261 By default the WordPress tasks that have been set up to run with wp-cron.php only run when a WordPress page is visited by a user, if the site has low traffic then tasks make take a while to action, if the site is high traffic and has caching then this can also cause reliability issues,…

The post Set up WordPress wp-cron.php to run via real cron in cPanel, Cloudways and with Caching appeared first on WP Beaches.

]]>
By default the WordPress tasks that have been set up to run with wp-cron.php only run when a WordPress page is visited by a user, if the site has low traffic then tasks make take a while to action, if the site is high traffic and has caching then this can also cause reliability issues, instead you can manually set up the cron tasks to run at a timed schedules instead.

Disable default WordPress wp-cron.php

Disable the default WordPress cron behaviour by adding a PHP constant to wp-config.php

define('DISABLE_WP_CRON', true);

Now wp-cron won’t run, but you’ll have to now set up a manual cron job on your hosting platform, below are 2 ways with Cloudways and cPanel.

Set up WordPress cron with Cloudways

Go to Application Management > Cron Job Management > Add New Cron Job

Cloudways Add Cron

 

In the next screen add the location path of the wp-cron.php file and how often you want to run it, my example runs it every 30 mins.

(By setting the cron job up with the Basic tab in Cloudways, the task is automatically run by PHP, whereas in cPanel you need to explicitly add the PHP path. If you swap to the Advanced tab in Cloudways you’ll see the PHP path in full)

Cloudways Add Cron Schedule

 

Set up WordPress cron with cPanel

In cPanel search for Cron and add a new one.

Cpanel Add WordPress Cron

 

Make sure add the correct path to wp-cron.php, also you need to run the file as the PHP user, so set the PHP path prefixing the cron file with a space in between.

Then set a schedule, this example sets a 10min interval, you also have an option of an email alert if you want to make sure the cron has run.

 

Viewing and Running wp-cron.php with WP Crontrol plugin

Wp Cron Control Plugin

WP Crontrol plugin can show you a list of tasks or events that are scheduled to run, you can edit, delete or run the tasks now, this is a good way to troubleshoot events that are stuck or past the time.

Viewing and Running wp-cron.php with WP CLI

With WP CLI installed you can list all events.

wp cron event list

You should see output like…

+-------------------------------------------+---------------------+-----------------------+---------------+
| hook                                      | next_run_gmt        | next_run_relative     | recurrence    |
+-------------------------------------------+---------------------+-----------------------+---------------+
| jetpack_v2_heartbeat                      | 2019-10-17 03:56:45 | now                   | 1 day         |
| action_scheduler_run_queue                | 2019-10-17 04:00:08 | now                   | 1 minute      |
| jetpack_sync_cron                         | 2019-10-17 04:01:42 | now                   | 5 minutes     |
| jetpack_sync_full_cron                    | 2019-10-17 04:01:42 | now                   | 5 minutes     |
| prli_cleanup_visitor_locks_worker         | 2019-10-17 04:16:11 | now                   | 1 hour        |
| jetpack_clean_nonces                      | 2019-10-17 04:23:01 | now                   | 1 hour        |
| wp_privacy_delete_old_export_files        | 2019-10-17 04:39:57 | now                   | 1 hour        |

The tasks or hook names are on the left and the other columns list their run time and frequency

To run all events due now…

wp cron event run --due-now

To run a specific event now, choose the hook name…

wp cron event run jetpack_v2_heartbeat

Running wp-cron when site is fully cached

If you have a fully cached site and your event hooks are not running, try this cron command instead…

wget -q -O - https://examplesite.com/wp-cron.php?doing_wp_cron

I have experienced a site cached with Swift Performance Lite that was not running the scheduled cron tasks, the cron command above fixed it which I found referenced at Siteground hosting.

Remote crons

You can also use remote cron service instead to schedule tasks, one such is https://cron-job.org which is free, there are others and paid solutions too.

That’s it, with WP CLI it makes it easy to troubleshoot and see what is going on and generally setting the cron to run on a set basis makes for better cron allround.

The post Set up WordPress wp-cron.php to run via real cron in cPanel, Cloudways and with Caching appeared first on WP Beaches.

]]>
https://wpbeaches.com/set-up-wordpress-wp-cron-php-to-run-manually/feed/ 0 16261
Getting Browsersync running with Gulp 4 and Valet https://wpbeaches.com/getting-browsersync-running-with-gulp-4-and-valet/ https://wpbeaches.com/getting-browsersync-running-with-gulp-4-and-valet/#comments Mon, 11 Nov 2019 04:39:29 +0000 https://wpbeaches.com/?p=16374 Get Browsersync going with Gulp 4+ and Valet as a local development environment. With Gulp 4+ there has been some code upgrades that require any older gulp.js files to be updated, this guide looks at making Browsersync work with Gulp with the local development tool being Valet. nodejs Ensure you already have nodejs and npm…

The post Getting Browsersync running with Gulp 4 and Valet appeared first on WP Beaches.

]]>
Get Browsersync going with Gulp 4+ and Valet as a local development environment. With Gulp 4+ there has been some code upgrades that require any older gulp.js files to be updated, this guide looks at making Browsersync work with Gulp with the local development tool being Valet.

nodejs

Ensure you already have nodejs and npm installed, you can do this via Homebrew or a direct install from Node. Current stable long term version is 12. You can check your node version with …

node --v

Gulp

Next get Gulp installed, if you have an existing install check your versions…

gulp --v

You will see 2 versions if the path you are in already has an npm package.json file, Gulp 4+ has changed from previous versions.

CLI version: 2.2.0
Local version: 4.0.2

If you are missing either, you can install the CLI version with …

npm install --global gulp-cli

And your local package version should be added to a directory already with a package.json file, if not run npm init and then run…

npm install --save-dev gulp

Browsersync

Install Browsersync…

npm install browser-sync --save-dev

package.json

Your package.json file should resemble this…

{
  "name": "project_name",
  "version": "1.0.0",
  "description": "description",
  "repository": {
    "type": "git",
    "url": "?.git"
  },
  "author": "author",
  "devDependencies": {
    "browser-sync": "^2.26.7",
    "gulp": "^4.0.2",
  }
}

Create a gulp.js file

const gulp = require("gulp");
const browserSync = require("browser-sync").create();
const sitename = 'gulp'; // set your siteName here
const username = 'neilg'; // set your macOS userName here


  function watch() {
    browserSync.init({

       // proxy: sitename +'.test',
        // or if site is http comment out below block and uncomment line above
      	 proxy: 'https://' + sitename + '.test',
               host: sitename + '.test',
               open: 'external',
               port: 8000,
               https: {
                   key:
                       '/Users/' + username + '/.config/valet/Certificates/' + sitename + '.test.key',
                   cert:
                       '/Users/' + username + '/.config/valet/Certificates/' + sitename + '.test.crt',
         	      },	
    });

	// Watched files paths
	gulp.watch('./*.php').on('change',browserSync.reload);
	gulp.watch('./js/*.js').on('change', browserSync.reload);
	gulp.watch('./css/*.css').on('change', browserSync.reload);
	gulp.watch('./*css').on('change', browserSync.reload);
}

exports.default = watch;

Set the username and site name variables, choose either http v https for the browser reload and update any paths you need watched.

I have found some issues with regular http sites reloading with macOS Catalina so I make all sites with https with…

wp valet secure <sitename>

Run gulp

Now from within the project directory you can run the default gulp task…

gulp

Now browsersync will reload on any file changes.

Please note the server is set up as proxy to place nicely with Valet – if you are not using Valet or a similar local dev but instead a server app like set up see the browsersync docs.

The post Getting Browsersync running with Gulp 4 and Valet appeared first on WP Beaches.

]]>
https://wpbeaches.com/getting-browsersync-running-with-gulp-4-and-valet/feed/ 2 16374
Adding Expires Header to htaccess https://wpbeaches.com/adding-expires-header-to-htaccess/ https://wpbeaches.com/adding-expires-header-to-htaccess/#respond Sat, 09 Nov 2019 22:50:19 +0000 https://wpbeaches.com/?p=16364 Expires Headers are a set of rules or directives from a website to tell a user’s local browser to either look in its own cache for files or to request the files off the webserver, the former is better for speed of the web page load and a reduction in the webserver processing. For Apache…

The post Adding Expires Header to htaccess appeared first on WP Beaches.

]]>
Expires Headers are a set of rules or directives from a website to tell a user’s local browser to either look in its own cache for files or to request the files off the webserver, the former is better for speed of the web page load and a reduction in the webserver processing.

For Apache webservers you add the directives in the .htaccess file.

<IfModule mod_expires.c>
  ExpiresActive On

  # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Video
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"

  # Others
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType application/x-shockwave-flash "access plus 1 month"
  
  # Everything else
  ExpiresDefault "access 7 days"
 
</IfModule>


So in the file above certain file types are explicitly set with ‘ExpiresByType‘ with assets like images and videos set to be retained by a year and files like css and js files set to be retained by a month. Then all other files controlled by ‘ExpiresDefault‘ setting the cache time for 7 days this would include html/php files.

You can adjust these times to your preference.

Ref

The post Adding Expires Header to htaccess appeared first on WP Beaches.

]]>
https://wpbeaches.com/adding-expires-header-to-htaccess/feed/ 0 16364
Set Up Valet on macOS for Local WordPress Development https://wpbeaches.com/setting-up-valet-on-macos-for-local-wordpress-development/ https://wpbeaches.com/setting-up-valet-on-macos-for-local-wordpress-development/#comments Fri, 25 Oct 2019 03:41:16 +0000 http://wpbeaches.com/?p=14637 This is a guide on how to set up Laravel Valet on macOS for a WordPress local development environment. Using Valet as a WordPress local development solution has the main benefits of speed, being lightweight and using fewer configurations to go wrong than say a solution like Vagrant. There is a 2nd related article that…

The post Set Up Valet on macOS for Local WordPress Development appeared first on WP Beaches.

]]>
This is a guide on how to set up Laravel Valet on macOS for a WordPress local development environment. Using Valet as a WordPress local development solution has the main benefits of speed, being lightweight and using fewer configurations to go wrong than say a solution like Vagrant.

There is a 2nd related article that looks at getting WordPress themes, plugins and settings already installed and ready to deploy.

Valet runs only on macOS and runs directly on top of the operating system, not in a virtual container.

The key software components needed are Homebrew; a package manager and Laravel; a PHP framework.

Valet itself has an Nginx, PHP 7.3 and DnsMasq and by default uses the .test domain name, you add in a database MariaDB or MySQL. Once the software is all installed Valet itself will launch automatically on startup of macOS.

Set Up Local Development Environment

Install Homebrew

First up is to install Homebrew so the key parts of the web stack such as PHP and MySQL/MariaDB can get installed easily.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This will install the Homebrew package manager and Xcode command line tools if not already installed.

Install composer with Homebrew

brew install composer

Get PHP and MySQL set up

Install PHP

brew install php

For the database you can choose between MariaDB and MySQL and which version of MySQL, since version 8 is not supported at a number of hosting panels, version 5.7 maybe safer – otherwise drop the @5.7 suffix. For mariaDB I would use 10.3 as 10.4 has some root password changes.

Also if you are using a version of the app using @10.3 etc, after install you need to add the path to your shell as it is an older Homebrew formula, you are remonded of this at the shell prompt after Homebrew installs – example below of path with mariaDB path in .bash_profile

export PATH="/usr/local/opt/mariadb@10.3/bin:~/bin:~/.composer/vendor/bin:/usr/local/sbin:$PATH"

Install MySQL/MariaDB – background service works after restart

brew install mariadb@10.3

or…

brew install mysql@5.7

Start it as background service

brew services start mariadb@10.3
or...
brew services start mysql@5.7

MySQL/MariaDB installs as user root with no password.

Get Laravel and Valet set up

Install Laravel

composer global require "laravel/installer"

Install Valet with composer

composer global require laravel/valet

Make sure your macOS shell path has the following location, this will allow you to easily use valet commands on the command line – if you don’t include it you will need to prefix all valet commands with ~/.composer/vendor/bin/

~/.composer/vendor/bin

Install valet

valet install

Now it will install dnsmasq and set up Nginx and PHP and start valet, some basic valet commands below…

valet stop
valet restart
valet --version

Do a ping test to a fictitious domain, look for some pingbacks from 127.0.0.1

ping blah.test

A responding ping will verify dnsmasq and the other components have been successfully set up.

Confirm you have dnsmaq, mysql, Nginx and php running…

brew services list

Output should be…

admin@192-168-1-104 ~ % brew services list
Name      Status  User  Plist
dnsmasq   started root  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mysql@5.7 started admin /Users/admin/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
nginx     started root  /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root  /Library/LaunchDaemons/homebrew.mxcl.php.plist

To update Laravel Valet

composer global update
valet install
valet restart

Webroot & park

Probably the best method for a webroot directory is to use the Sites folder in your home, this was a traditional webroot in the past of the macOS user account filing system – if one is not there either make one in the Finder or via the Terminal

mkdir ~/Sites

Register the Sites folder with Valet, so any top level folders will be treated as a serving site – use the park command

cd ~/Sites
valet park

There is also a valet link command that allows a directory somewhere else in the filing system to serve its content as a webroot, it does so by putting a symbolic link in the park directory – Sites.

To set up new Laravel project sites you can use the command

laravel new sitename

The first site created this wat takes a while with a number of downloads when it is done a new http://sitename.test is viewable in the browser – but what about with an actual WordPress install?  – see next.

 

WordPress and Valet

So the best code to serve up ready made WordPress sites is wp-cli-valet-command it can spin up sites very quickly and can be further enhanced taking advantage of bash scripting.

First of all, you need to have wp-cli installed, use Homebrew to install or manually this guide can cover that process.

brew install wp-cli

Increase your PHP memory size, especially if you installed PHP with Homebrew – otherwise, a fatal error will occur when installing wp-cli-valet-command package, find your PHP memory limits .ini config file

php --ini
nano /usr/local/etc/php/7.3/conf.d/php-memory-limits.ini

Change limits to 1024M in all 3 places

Also, make sure your MySQL or mariadb is running…

brew services start mariadb

Once you have wp-cli add the wp-cli-valet-command package

wp package install git@github.com:aaemnnosttv/wp-cli-valet-command.git

Once this is installed you are ready to create some WordPress sites…

To install a new site, move into your Sites folder and run a wp valet command

cd ~/Sites
wp valet new newsitename

This will set up https://newsitename.test ready to go WP-Admin defaults are admin/admin for username and password.

All new sites are by default set up with https – to set one up just as http – run…

wp valet new newsitename --unsecure

To remove a site…

wp valet destroy newsitename

For more commands and options check out the GitHub repo for wp-cli-valet and also you can create custom sites with a certain theme, plugins, etc by rolling your own bash scripts.

Toggle SSL

To toggle between whether or not a site uses an SSL cert..

valet unsecure mysitename

or

valet secure mysitename

Terminal output

Restarting nginx...
The [mysitename.test] site has been secured with a fresh TLS certificate.

 

phpMyAdmin

To deal with MySQL via phpmyAdmin – create a new site

cd ~/Sites
wp valet new phpmyadmin

So now you have a https://phpmyadmin.test – remove all the WordPress files and download and move into the folder the latest phpmyadmin files – if your MySQL install is no password then change the config file as prompted to AllowNoPassword. Now all your databases are easily accessible.

You can take WordPress site installation further with Valet by adding a bash script that includes further refining the install with plugins and themes tailoring – see the next article on Valet, wp-cli and bash scripting.

 

mariaDB 10.4 ERROR 1698 (28000): Access denied for user ‘root’@’localhost’

Since v10.4 mariadb has had some root/password major changes, if you are getting this error  when creating new sites with valet use your macos shortname instead with a db user variable like so…

wp valet new sitename --dbuser="admin"

So a new site ‘sitename’ is created with the macOS shortname of the account ‘admin’

Toggling PHP Versions

The initial PHP Hombrew downloaded version is 7.3, you can add other PHP versions and set Valet to use a different version…

valet use php@7.2

Valet will download PHP7.2 via HomeBrew and use it, you can also use…

valet use php@7.1

Using PHP 5.6

To use PHP 5.6 you need to add an unofficial Homebrew tap as these have been removed from regular Homebrew taps.

brew tap exolnet/homebrew-deprecated

Then try Valet

valet use php@5.6

If you get a syntax error .composer/vendor/illuminate/support/Collection.php on line 103 – run…

composer global update

Using Valet without an admin password

The default behaviour is for an admin password to be requested for each valet command, this can be surpasses with…

valet trust

Which allows both valet and Homebrew commands to be password free.

Sudoers entries have been added for Brew and Valet.

References

Install valet

Install wp-cli-valet-command

Install wp-cli

Install Homebrew

Older PHP 5.6 & 7

The post Set Up Valet on macOS for Local WordPress Development appeared first on WP Beaches.

]]>
https://wpbeaches.com/setting-up-valet-on-macos-for-local-wordpress-development/feed/ 8 14637
Block xmlrpc.php requests from Cloudflares firewall apart from JetPack https://wpbeaches.com/block-xmlrpc-php-from-cloudflare-apart-from-jetpack/ https://wpbeaches.com/block-xmlrpc-php-from-cloudflare-apart-from-jetpack/#respond Tue, 15 Oct 2019 00:41:36 +0000 https://wpbeaches.com/?p=16240 You can block WordPress xmlrpc.php requests from Cloudflare but exclude the JetPack IP addresses by creating a custom firewall rule, attacks on xmlrpc.php are frequent and it is best now disabled as it will be deprecated from WordPress in the future. However, some of the more popular WordPress plugins such as JetPack still need to…

The post Block xmlrpc.php requests from Cloudflares firewall apart from JetPack appeared first on WP Beaches.

]]>
You can block WordPress xmlrpc.php requests from Cloudflare but exclude the JetPack IP addresses by creating a custom firewall rule, attacks on xmlrpc.php are frequent and it is best now disabled as it will be deprecated from WordPress in the future.

However, some of the more popular WordPress plugins such as JetPack still need to access xmlrpc.php so you may need a custom solution to make it available.

Fully Disable xmlrpc.php

You can fully disable xmlrpc.php with a plugins such as perfmatters or Disable XML-RPC or a line of code in your functions.php

add_filter( 'xmlrpc_enabled', '__return_false' );

Check that xmlrpc is disabled with this online validator.

Online Xmlrpc Validator

Partially Disable xmlrpc.php localhost

You can restrict usage by partially blocking access to xmlrpc.php by adding a rule in your .htaccess file

<Files xmlrpc.php>
Order allow,deny
Allow from 192.0.64.0/18
Deny from all Satisfy All ErrorDocument 403 http://127.0.0.1/ </Files>

So only IP addresses in the range of 192.0.64.0/18 can access xmlrpc.php  – which is part of the JetPack IP address range.

Partially Disable xmlrpc.php at Cloudflare but allow JetPack

With the free Cloudflare you can add up to five custom firewall rules, create one to block all IP addresses apart from JetPacks to deny access to any query string that contains xmlrpc.php

Cloudflare Firewall Xmlrpc Rule Create

Create a custom firewall rule

 

 

Cloudflare Firewall Xmlrpc Rule

Add in the range of IP addresses and URI path that contains xmlrpc.php

 

JetPack IP Address Range

The JetPack IP address range is discussed on Github, published at JetPack, but is subject to change which can be verified here, and converted to CIDR notation here.

 

Now you can check the activity of the firewall rule by clicking on the Activity last 24hr link in the rule – also verify your xmlrpc.php is disabled by visiting the online validator.

The post Block xmlrpc.php requests from Cloudflares firewall apart from JetPack appeared first on WP Beaches.

]]>
https://wpbeaches.com/block-xmlrpc-php-from-cloudflare-apart-from-jetpack/feed/ 0 16240
Change WooCommerce Sold Out text https://wpbeaches.com/change-woocommerce-sold-out-text/ https://wpbeaches.com/change-woocommerce-sold-out-text/#respond Mon, 14 Oct 2019 01:31:21 +0000 https://wpbeaches.com/?p=16231 You can change WooCommerce ‘Sold Out’ text set by the inventory setting of Sold Out with the WooCommerce filter woocommerce_get_availability_text Add the below snippet with your custom sold text to functions.php add_filter('woocommerce_get_availability_text', 'themeprefix_change_soldout', 10, 2 ); /** * Change Sold Out Text to Something Else */ function themeprefix_change_soldout ( $text, $product) { if ( !$product->is_in_stock()…

The post Change WooCommerce Sold Out text appeared first on WP Beaches.

]]>
You can change WooCommerce ‘Sold Out’ text set by the inventory setting of Sold Out with the WooCommerce filter woocommerce_get_availability_text

Add the below snippet with your custom sold text to functions.php

add_filter('woocommerce_get_availability_text', 'themeprefix_change_soldout', 10, 2 );
 /**
  * Change Sold Out Text to Something Else
  */
function themeprefix_change_soldout ( $text, $product) {
    
    if ( !$product->is_in_stock() ) {
        $text = '<div class="alert-info">You missed us - sold out already! If you’d like us to produce more stock then drop us a line and let us know. </div>'; 
        } 
    return $text; 
}

The post Change WooCommerce Sold Out text appeared first on WP Beaches.

]]>
https://wpbeaches.com/change-woocommerce-sold-out-text/feed/ 0 16231
Using WooCommerce with Varnish, exclude pages and cookies https://wpbeaches.com/using-woocommerce-with-varnish-exclude-pages-and-cookies/ https://wpbeaches.com/using-woocommerce-with-varnish-exclude-pages-and-cookies/#respond Sun, 13 Oct 2019 05:09:04 +0000 https://wpbeaches.com/?p=16212 To use WooCommerce with Varnish server-side caching you need to exclude some of the generic WooCommerce pages and cookies. Some web hosts will partially do this for you and others will give you an interface to add them yourself, make sure you ask the host what options are available Exclude from Varnish these WooCommerce pages…

The post Using WooCommerce with Varnish, exclude pages and cookies appeared first on WP Beaches.

]]>
To use WooCommerce with Varnish server-side caching you need to exclude some of the generic WooCommerce pages and cookies. Some web hosts will partially do this for you and others will give you an interface to add them yourself, make sure you ask the host what options are available

Exclude from Varnish these WooCommerce pages

  • cart
  • my-account
  • checkout
  • addons
  • \?add-to-cart=
  • add-to-cart

Exclude from Varnish these WooCommerce cookies

  • woocommerce_cart_hash
  • woocommerce_items_in_cart
  • wp_woocommerce_session_

Some WordPress friendly hosts will have some or all of this configuration done for you, Cloudways for instance use a woocommerce.vcl (varnish config. language file) which has the WooCommerce pages already excluded…

# Do not cache the WooCommerce pages
### REMOVE IT IF YOU DO NOT USE WOOCOMMERCE ###
if (req.url ~ "/(cart|my-account|checkout|addons|\?add-to-cart=|add-to-cart)") {
return (pipe);
}

This file is located in..

/etc/varnish/recv/woocommerce.vcl

For the cookie exclusion you should be able to add cookies via your hosts’ interface, in Cloudways interface this is done per web app under the Apps > Application Management > Application Settings > Varnish Settings.

Woocommerce Cookies Varnish

 

In this interface you can also exclude URLs which are a selection in the Type, either pick a URL or a Cookie that you want to exclude.

 

Woocommerce Exclude Url Cookie

That’s it, now these WooCommerce pages and cookies won’t be server-side cached.

The post Using WooCommerce with Varnish, exclude pages and cookies appeared first on WP Beaches.

]]>
https://wpbeaches.com/using-woocommerce-with-varnish-exclude-pages-and-cookies/feed/ 0 16212
Redirect all pages to non-www and HTTPS in WordPress https://wpbeaches.com/redirect-all-pages-to-non-www-and-https-in-wordpress/ https://wpbeaches.com/redirect-all-pages-to-non-www-and-https-in-wordpress/#respond Sun, 13 Oct 2019 02:45:00 +0000 https://wpbeaches.com/?p=16207 To redirect all URLs from www to non-www and also to redirect from http to https, this code snippet to be added to .htaccess file at the top should do the trick. So https://example.com # BEGIN Redirects RewriteEngine On # 301 redirect www to non-www RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] # 301…

The post Redirect all pages to non-www and HTTPS in WordPress appeared first on WP Beaches.

]]>
To redirect all URLs from www to non-www and also to redirect from http to https, this code snippet to be added to .htaccess file at the top should do the trick.

So https://example.com

# BEGIN Redirects
RewriteEngine On
# 301 redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# 301 redirect to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# END Redirects

If you still want the www way instead https://www.example.com

# BEGIN Redirects
RewriteEngine On
# 301 redirect to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 301 redirect to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# END Redirects

The post Redirect all pages to non-www and HTTPS in WordPress appeared first on WP Beaches.

]]>
https://wpbeaches.com/redirect-all-pages-to-non-www-and-https-in-wordpress/feed/ 0 16207
Create An ACF Repeater Bootstrap Accordion in WordPress https://wpbeaches.com/create-an-acf-repeater-bootstrap-accordion-in-wordpress/ https://wpbeaches.com/create-an-acf-repeater-bootstrap-accordion-in-wordpress/#comments Sun, 06 Oct 2019 05:07:43 +0000 https://wpbeaches.com/?p=16179 Create An ACF Repeater Bootstrap Accordion for use in WordPress. Accordions can be a handy way of managing larger amounts of data to display only certain bits at a time this guide shows how to use a Boostrap accordion with ACF, a non-bootstrap guide is here. Create the ACF Repeater fields for the Bootstrap accordion.…

The post Create An ACF Repeater Bootstrap Accordion in WordPress appeared first on WP Beaches.

]]>
Create An ACF Repeater Bootstrap Accordion for use in WordPress.

Accordions can be a handy way of managing larger amounts of data to display only certain bits at a time this guide shows how to use a Boostrap accordion with ACF, a non-bootstrap guide is here.

Create the ACF Repeater fields for the Bootstrap accordion.

Accordion Acf Repeater

 

You can create as many accordion fields as needed, assign the field group to a post or page and populate the repeater rows.

Accordion Acf Repeater Rows

Add the ACF Repeater Loop Bootstrap Accordion Code

View the code on Gist.

Fred Perry
The brand founded by triple Wimbledon champion Fred Perry in 1952 and adopted by generations of British subcultures ever since. T
S,M,L,XL,XXL,XXXL
Red, Green, Blue

 

Shortcode Version

You can also do it as a shortcode and insert the loop.

View the code on Gist.

 

Some more options here.

The post Create An ACF Repeater Bootstrap Accordion in WordPress appeared first on WP Beaches.

]]>
https://wpbeaches.com/create-an-acf-repeater-bootstrap-accordion-in-wordpress/feed/ 1 16179
Create A Bootstrap 4 Carousel Slider With ACF Image Repeater https://wpbeaches.com/create-a-bootstrap-4-carousel-slider-with-acf-image-repeater/ https://wpbeaches.com/create-a-bootstrap-4-carousel-slider-with-acf-image-repeater/#comments Sun, 06 Oct 2019 01:02:29 +0000 https://wpbeaches.com/?p=16109 Create a Bootstrap 4 carousel slider of images with ACF Pro Repeater field in WordPress. There are a few options in that the carousel can be plain, add navigation and add a caption, 4 examples can be seen below.   Create the ACF Repeater fields for Bootstrap carousel.   Here an image and text field…

The post Create A Bootstrap 4 Carousel Slider With ACF Image Repeater appeared first on WP Beaches.

]]>
Create a Bootstrap 4 carousel slider of images with ACF Pro Repeater field in WordPress. There are a few options in that the carousel can be plain, add navigation and add a caption, 4 examples can be seen below.

 

Create the ACF Repeater fields for Bootstrap carousel.

Bootstrap Carousel Acf

 

Here an image and text field are created, assign the field group to a post or page and populate the repeater rows.

Acf Populate Carousel Fields

 

Add the ACF Repeater Bootstrap Carousel Code

View the code on Gist.

View the code on Gist.

View the code on Gist.

View the code on Gist.
View the code on Gist.

There are 5 code snippets above, expand to see the code, they are a plain carousel slider, a slider with navigation and indicators and carousel with text captions, the PHP counter increment variable is used throughout.
Ensure you have unique IDs per slider.

Add more options to the slider either via data attributes or Javascript.

The post Create A Bootstrap 4 Carousel Slider With ACF Image Repeater appeared first on WP Beaches.

]]>
https://wpbeaches.com/create-a-bootstrap-4-carousel-slider-with-acf-image-repeater/feed/ 3 16109