Scroll to Element with jQuery

Scroll to element #scrollToElementId when element #btn is clicked.


Activate and delete themes with WP-CLI

Activate theme
$ wp theme activate your_theme_name

Delete theme
$ wp theme delete your_theme_name

 More commands

PHP WordPress

Remove automatically inserted paragraph tags from Contact Form 7

Add following line to your wp-config.php

define( 'WPCF7_AUTOP', false );


PHP WordPress

Exclude pages from WordPress search

To exclude page from search, add following code to your theme’s functions.php.

Exclude page and all it’s child pages from search.


Install WordPress plugins with WP-CLI

Install plugin
$ wp plugin install w3-total-cache

Install and activate plugin
$ wp plugin install w3-total-cache --activate

Plugins can be installed by plugin slug, path to local zip file or external URL. See more options at WP-CLI documentation


Install WordPress with WP-CLI

Download WordPress core files

$ wp core download

You can download WordPress in your language with adding option
--locale=your_language_code to the command. Check the list of localizations for your locale. See documentation for all the other options.

Create wp-config.php file

$ wp core config --dbname=your_db --dbuser=your_db_user --dbpass=your_db_password --dbhost=your_db_host

Required parameters are:

  • dbname: Database name
  • dbuser: Database user name
  • dbpass: Database password
  • dbhost: Database host

See documentation for optional parameters

Create WordPress tables

$ wp core install --url="" --title="Your blog" --admin_user="admin_user_name" --admin_password="admin_pwd" --admin_email="your_email"

Required parameters are:

  • url: Your site url
  • title: Your site title
  • admin_user: Admin user name
  • admin_password: Password for admin user
  • admin_email: Admin users email address

Now you should see a line that says
Success: WordPress installed successfully.

Read more about wp-cli commands


Zoom To Fit All Markers on Google Maps

Zoom Google Maps to fit all markers on your map.

var latLngArr = [new google.maps.LatLng(52.537,-2.061), new google.maps.LatLng(52.564,-2.017)],
    bounds = new google.maps.LatLngBounds(),
    idx = 0,
    count = latLngArr.length;

for ( ; idx < count; idx++) {
  bounds.extend (latLngArr[idx]);

PHP WordPress

Get translated permalink with WPML

For WPML 3.2+ correct version for translating permalinks is

Documentation for wpml_object_id

For versions older than 3.2 you can use version below

Parameters for icl_object_id are:

  • Term id for taxonomies, post id for posts and pages
  • Element type ie. comment, post or page
  • Return original value if translation is missing. Defaults to true
  • Language code, if missing will use the current language.