Using WordPress as a Headless CMS

A Headless CMS Defined In the simplest of terms, a headless CMS is one that has no front end. As such, it includes just the API and the back end that is required to store and manage content, organize data and handle the workflow. There’s no front end display of the said content. Naturally, this … Read more

is_archive()

Determines whether the query is for an existing archive page. Archive pages include category, tag, author, date, custom post type, and custom taxonomy based archives. For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook. See also is_category() is_tag() is_author() is_date() is_post_type_archive() is_tax()

How to Add Categories to a Custom Post Type in WordPress

To display your custom post types on the same category page as your default posts, you need to add this code into your theme’s functions.php or a site-specific plugin. add_filter(‘pre_get_posts’, ‘query_post_type’); function query_post_type($query) {   if( is_category() ) {     $post_type = get_query_var(‘post_type’);     if($post_type)         $post_type = $post_type;     else         $post_type = array(‘nav_menu_item’, ‘post’, ‘movies’); // don’t forget nav_menu_item … Read more

How to Display Custom Post Type Category (With Name & Link!)

Get Category of a Custom Post Type To get categories of a custom post type and display them along with their respective posts, I will use the the_terms() function inside the loop. the_terms() function display all the associated categories of a custom post type. It requires two parameters, post_id and taxonomy slug.

WP_Query

Taxonomy Parameters Show posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. (Deprecated since version 3.1 in favor of ‘tax_query‘). tax_query (array) – use taxonomy parameters (available since version 3.1). relation (string) – The logical relationship between each inner taxonomy array when there is more than one. Possible values are ‘AND’, ‘OR’. Do not use with a … Read more

How To Use WP_Query In WordPress

The WP_Query class is one of the most important parts of the WordPress codebase. Among other things, it determines the query you need on any given page and pulls posts accordingly. It also saves a lot of information about the requests it makes, which helps a great deal when optimizing pages (and troubleshooting them). The other role … Read more

WordPress REST API: What It Is and How to Get Started Using It

There are five basic elements that make an API ‘RESTful’. Keep in mind that the ‘server’ is the platform the API belongs to, and the ‘client’ is the site, application, or software connecting to that platform: Client-server architecture. The API should be built so that the client and the server remain separate from one another. That way they … Read more

WordPress REST API Handbook

The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects. It is the foundation of the WordPress Block Editor, and can likewise enable your theme, plugin or custom application to present new, powerful interfaces for managing and publishing your site content. … … Read more