Check which template loading in WordPress site

Below is the simple function which you can use for debugging the site. It  display the template file path of the current page. Like below image:

Add below code snippet into your themes functions.php file.

Advertisements

WordPress Rest API query parameters mappings

This array defines mappings between public API query parameters whose values are accepted as-passed, and their internal WP_Query parameter name equivalents (some are the same). Only values which are also present in registered will be set.

Below is the list of all the endpoints which have query parameters mapping:

  • wp/v2/comments
  • wp/v2/<post-type>
  • wp/v2/<taxonomy>
  • wp/v2/<term>
  • wp/v2/<users>

Check below list of parameters mapping by Rest API endpoints:

wp/v2/comments

$parameter_mappings = array(
    'author'         => 'author__in',
    'author_email'   => 'author_email',
    'author_exclude' => 'author__not_in',
    'exclude'        => 'comment__not_in',
    'include'        => 'comment__in',
    'offset'         => 'offset',
    'order'          => 'order',
    'parent'         => 'parent__in',
    'parent_exclude' => 'parent__not_in',
    'per_page'       => 'number',
    'post'           => 'post__in',
    'search'         => 'search',
    'status'         => 'status',
    'type'           => 'type',
);

wp/v2/<post-type>

$parameter_mappings = array(
    'author'         => 'author__in',
    'author_exclude' => 'author__not_in',
    'exclude'        => 'post__not_in',
    'include'        => 'post__in',
    'menu_order'     => 'menu_order',
    'offset'         => 'offset',
    'order'          => 'order',
    'orderby'        => 'orderby',
    'page'           => 'paged',
    'parent'         => 'post_parent__in',
    'parent_exclude' => 'post_parent__not_in',
    'search'         => 's',
    'slug'           => 'post_name__in',
    'status'         => 'post_status',
);

wp/v2/<taxonomy>

$parameter_mappings = array(
    'exclude'    => 'exclude',
    'include'    => 'include',
    'order'      => 'order',
    'orderby'    => 'orderby',
    'post'       => 'post',
    'hide_empty' => 'hide_empty',
    'per_page'   => 'number',
    'search'     => 'search',
    'slug'       => 'slug',
);

wp/v2/<term>

       
$parameter_mappings = array(
    'exclude'    => 'exclude',
    'include'    => 'include',
    'order'      => 'order',
    'orderby'    => 'orderby',
    'post'       => 'post',
    'hide_empty' => 'hide_empty',
    'per_page'   => 'number',
    'search'     => 'search',
    'slug'       => 'slug',
);

wp/v2/<users>

$parameter_mappings = array(
    'exclude'  => 'exclude',
    'include'  => 'include',
    'order'    => 'order',
    'per_page' => 'number',
    'search'   => 'search',
    'roles'    => 'role__in',
    'slug'     => 'nicename__in',
);

Update PHP Codesniffer (PHPCS), WordPress Coding Standards (WPCS), PHP Compatibility (WIMG)

Update PHP Codesniffer (PHPCS), WordPress Coding Standards (WPCS), PHP Compatibility (WIMG)

Copy below individual or all command(s) to get latest update.

composer global require squizlabs/php_codesniffer
composer global require wp-coding-standards/wpcs
composer global require wimg/php-compatibility
composer global require dealerdirect/phpcodesniffer-composer-installer
phpcbf
phpcs

WordPress Rest API Get specific posts by IDs by using `include` parameter

With the Rest API we get all the posts. But, Sometimes we want to get only specific posts by post ids. WordPress have rest API parameter include which return only requested posts by post ids.

Syntax:
https://example.org/wp-json/wp/v2/posts?include=<post-ids&gt;

Example 1:
https://example.org/wp-json/wp/v2/posts?include=11,12
It return only 2 posts whose ids are 11 & 12.

Note: By default it return 10 posts. If you have more than 10 posts then add parameter `per_page` which return all the posts.

Example 2:
https://example.org/wp-json/wp/v2/posts/?include=18177,18178,18198,18258,18137,18138,18143,18144,18167,18166,18314,18322,18131,18135,18145,18156,18159,18158,18165,18169,18183,18185,18199,18227,18253,18262,18263,18283,18312,18325,18330,18329,18332,18333,18140,18152,18163,18180,18193,18191,18195,18200,18204,18205,18214,18218,18219,18221,18224,18242,18252,18273,18286,18288,18307&amp;per_page=100

WP CLI Commands Cheat Sheet (Complete List of WP CLI Commands)

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installs and much more, without using a web browser.

Below is the complete list of WP CLI commands generated with WP CLI Commands Cheat Sheet (Complete List of WP CLI Commands)

Cache
wp cache add Docs | Git
wp cache decr Docs | Git
wp cache delete Docs | Git
wp cache flush Docs | Git
wp cache get Docs | Git
wp cache incr Docs | Git
wp cache replace Docs | Git
wp cache set Docs | Git
wp cache type Docs | Git
Cap
wp cap add Docs | Git
wp cap list Docs | Git
wp cap remove Docs | Git
Cli
wp cli alias Docs | Git
wp cli check-update Docs | Git
wp cli cmd-dump Docs | Git
wp cli completions Docs | Git
wp cli has-command Docs | Git
wp cli info Docs | Git
wp cli param-dump Docs | Git
wp cli update Docs | Git
wp cli version Docs | Git
Comment
wp comment approve Docs | Git
wp comment count Docs | Git
wp comment create Docs | Git
wp comment delete Docs | Git
wp comment exists Docs | Git
wp comment generate Docs | Git
wp comment get Docs | Git
wp comment list Docs | Git
wp comment meta Docs | Git
wp comment recount Docs | Git
wp comment spam Docs | Git
wp comment status Docs | Git
wp comment trash Docs | Git
wp comment unapprove Docs | Git
wp comment unspam Docs | Git
wp comment untrash Docs | Git
wp comment update Docs | Git
wp comment meta add Docs | Git
wp comment meta delete Docs | Git
wp comment meta get Docs | Git
wp comment meta list Docs | Git
wp comment meta patch Docs | Git
wp comment meta pluck Docs | Git
wp comment meta update Docs | Git
Config
wp config create Docs | Git
wp config delete Docs | Git
wp config get Docs | Git
wp config has Docs | Git
wp config list Docs | Git
wp config path Docs | Git
wp config set Docs | Git
Core
wp core check-update Docs | Git
wp core download Docs | Git
wp core install Docs | Git
wp core is-installed Docs | Git
wp core multisite-convert Docs | Git
wp core multisite-install Docs | Git
wp core update-db Docs | Git
wp core update Docs | Git
wp core verify-checksums Docs | Git
wp core version Docs | Git
Cron
wp cron event Docs | Git
wp cron schedule Docs | Git
wp cron test Docs | Git
wp cron event delete Docs | Git
wp cron event list Docs | Git
wp cron event run Docs | Git
wp cron event schedule Docs | Git
wp cron schedule list Docs | Git
Db
wp db check Docs | Git
wp db cli Docs | Git
wp db create Docs | Git
wp db drop Docs | Git
wp db export Docs | Git
wp db import Docs | Git
wp db optimize Docs | Git
wp db prefix Docs | Git
wp db query Docs | Git
wp db repair Docs | Git
wp db reset Docs | Git
wp db search Docs | Git
wp db size Docs | Git
wp db tables Docs | Git
Embed
wp embed cache Docs | Git
wp embed fetch Docs | Git
wp embed handler Docs | Git
wp embed provider Docs | Git
wp embed cache clear Docs | Git
wp embed cache find Docs | Git
wp embed cache trigger Docs | Git
wp embed handler list Docs | Git
wp embed provider list Docs | Git
wp embed provider match Docs | Git
Language
wp language core Docs | Git
wp language core activate Docs | Git
wp language core install Docs | Git
wp language core list Docs | Git
wp language core uninstall Docs | Git
wp language core update Docs | Git
Media
wp media image-size Docs | Git
wp media import Docs | Git
wp media regenerate Docs | Git
Menu
wp menu create Docs | Git
wp menu delete Docs | Git
wp menu item Docs | Git
wp menu list Docs | Git
wp menu location Docs | Git
wp menu item add-custom Docs | Git
wp menu item add-post Docs | Git
wp menu item add-term Docs | Git
wp menu item delete Docs | Git
wp menu item list Docs | Git
wp menu item update Docs | Git
wp menu location assign Docs | Git
wp menu location list Docs | Git
wp menu location remove Docs | Git
Network
wp network meta Docs | Git
wp network meta add Docs | Git
wp network meta delete Docs | Git
wp network meta get Docs | Git
wp network meta list Docs | Git
wp network meta patch Docs | Git
wp network meta pluck Docs | Git
wp network meta update Docs | Git
Option
wp option add Docs | Git
wp option delete Docs | Git
wp option get Docs | Git
wp option list Docs | Git
wp option patch Docs | Git
wp option pluck Docs | Git
wp option update Docs | Git
Package
wp package browse Docs | Git
wp package install Docs | Git
wp package list Docs | Git
wp package path Docs | Git
wp package uninstall Docs | Git
wp package update Docs | Git
Plugin
wp plugin activate Docs | Git
wp plugin deactivate Docs | Git
wp plugin delete Docs | Git
wp plugin get Docs | Git
wp plugin install Docs | Git
wp plugin is-installed Docs | Git
wp plugin list Docs | Git
wp plugin path Docs | Git
wp plugin search Docs | Git
wp plugin status Docs | Git
wp plugin toggle Docs | Git
wp plugin uninstall Docs | Git
wp plugin update Docs | Git
wp plugin verify-checksums Docs | Git
Post-type
wp post-type get Docs | Git
wp post-type list Docs | Git
Post
wp post create Docs | Git
wp post delete Docs | Git
wp post edit Docs | Git
wp post generate Docs | Git
wp post get Docs | Git
wp post list Docs | Git
wp post meta Docs | Git
wp post term Docs | Git
wp post update Docs | Git
wp post meta add Docs | Git
wp post meta delete Docs | Git
wp post meta get Docs | Git
wp post meta list Docs | Git
wp post meta patch Docs | Git
wp post meta pluck Docs | Git
wp post meta update Docs | Git
wp post term add Docs | Git
wp post term list Docs | Git
wp post term remove Docs | Git
wp post term set Docs | Git
Profile
wp profile eval-file Docs | Git
wp profile eval Docs | Git
wp profile hook Docs | Git
wp profile stage Docs | Git
Rewrite
wp rewrite flush Docs | Git
wp rewrite list Docs | Git
wp rewrite structure Docs | Git
Role
wp role create Docs | Git
wp role delete Docs | Git
wp role exists Docs | Git
wp role list Docs | Git
wp role reset Docs | Git
Scaffold
wp scaffold _s Docs | Git
wp scaffold block Docs | Git
wp scaffold child-theme Docs | Git
wp scaffold plugin-tests Docs | Git
wp scaffold plugin Docs | Git
wp scaffold post-type Docs | Git
wp scaffold taxonomy Docs | Git
wp scaffold theme-tests Docs | Git
Sidebar
wp sidebar list Docs | Git
Site
wp site activate Docs | Git
wp site archive Docs | Git
wp site create Docs | Git
wp site deactivate Docs | Git
wp site delete Docs | Git
wp site empty Docs | Git
wp site list Docs | Git
wp site mature Docs | Git
wp site option Docs | Git
wp site private Docs | Git
wp site public Docs | Git
wp site spam Docs | Git
wp site unarchive Docs | Git
wp site unmature Docs | Git
wp site unspam Docs | Git
wp site option add Docs | Git
wp site option delete Docs | Git
wp site option get Docs | Git
wp site option list Docs | Git
wp site option patch Docs | Git
wp site option pluck Docs | Git
wp site option update Docs | Git
Super-admin
wp super-admin add Docs | Git
wp super-admin list Docs | Git
wp super-admin remove Docs | Git
Taxonomy
wp taxonomy get Docs | Git
wp taxonomy list Docs | Git
Term
wp term create Docs | Git
wp term delete Docs | Git
wp term generate Docs | Git
wp term get Docs | Git
wp term list Docs | Git
wp term meta Docs | Git
wp term recount Docs | Git
wp term update Docs | Git
wp term meta add Docs | Git
wp term meta delete Docs | Git
wp term meta get Docs | Git
wp term meta list Docs | Git
wp term meta patch Docs | Git
wp term meta pluck Docs | Git
wp term meta update Docs | Git
Theme
wp theme activate Docs | Git
wp theme delete Docs | Git
wp theme disable Docs | Git
wp theme enable Docs | Git
wp theme get Docs | Git
wp theme install Docs | Git
wp theme is-installed Docs | Git
wp theme list Docs | Git
wp theme mod Docs | Git
wp theme path Docs | Git
wp theme search Docs | Git
wp theme status Docs | Git
wp theme update Docs | Git
wp theme mod get Docs | Git
wp theme mod remove Docs | Git
wp theme mod set Docs | Git
Transient
wp transient delete Docs | Git
wp transient get Docs | Git
wp transient set Docs | Git
wp transient type Docs | Git
User
wp user add-cap Docs | Git
wp user add-role Docs | Git
wp user create Docs | Git
wp user delete Docs | Git
wp user generate Docs | Git
wp user get Docs | Git
wp user import-csv Docs | Git
wp user list-caps Docs | Git
wp user list Docs | Git
wp user meta Docs | Git
wp user remove-cap Docs | Git
wp user remove-role Docs | Git
wp user reset-password Docs | Git
wp user session Docs | Git
wp user set-role Docs | Git
wp user spam Docs | Git
wp user term Docs | Git
wp user unspam Docs | Git
wp user update Docs | Git
wp user meta add Docs | Git
wp user meta delete Docs | Git
wp user meta get Docs | Git
wp user meta list Docs | Git
wp user meta patch Docs | Git
wp user meta pluck Docs | Git
wp user meta update Docs | Git
wp user session destroy Docs | Git
wp user session list Docs | Git
wp user term add Docs | Git
wp user term list Docs | Git
wp user term remove Docs | Git
wp user term set Docs | Git
Widget
wp widget add Docs | Git
wp widget deactivate Docs | Git
wp widget delete Docs | Git
wp widget list Docs | Git
wp widget move Docs | Git
wp widget reset Docs | Git
wp widget update Docs | Git

 

Search post by post meta with rest api.

Use filter rest_{$this->post_type}_query to add the post meta support in WP Rest API.

Use below code snippet to add the post meta support for post type Post.

Syntax:

http://mysite.com/wp-json/wp/v2/post?meta_key=<meta-key>&meta_value=<meta-value&gt;

How to use?

E.g. Get posts which post meta already-visited value is true.

http://mysite.com/wp-json/wp/v2/post?meta_key=already-visited&meta_value=true

Code Snippet:

Getting curl to output HTTP status code?

A more specific way to print out just the HTTP status code is something along the lines of:

Command:
curl -s -o /dev/null -w "%{http_code}" https://wordpress.org/

Output:
200

E.g.