{"id":55276,"date":"2022-05-23T09:42:18","date_gmt":"2022-05-23T09:42:18","guid":{"rendered":"\/tutorials\/?p=55276"},"modified":"2026-03-09T19:18:33","modified_gmt":"2026-03-09T19:18:33","slug":"wordpress-wp_query","status":"publish","type":"post","link":"\/ng\/tutorials\/wordpress-wp_query","title":{"rendered":"How to sue WordPress WP_Query? Examples with code"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>By default, WordPress automatically sorts your posts from newest to oldest. Although visitors can search for specific posts using categories and tags, they might not be able to find the content they&rsquo;re looking for. To curate your posts for each visitor, it can be helpful to use <strong>WordPress WP_Query<\/strong>.<\/p><p>Using WP_Query, you can customize the display of your website&rsquo;s posts and pages. This PHP class enables you to simplify complex database requests. As a developer or website owner, it can help you customize pages beyond your default theme.<\/p><p>In this post, we&rsquo;ll explain what WP_Query is. Then, we&rsquo;ll show you how to use it on your WordPress website. Finally, we&rsquo;ll give you some examples of ways to implement it on your blog. Let&rsquo;s get started!<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Mega-WordPress-Cheat-EN.pdf\">Download all-in-one WordPress cheat sheet<\/a><\/p><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-an-introduction-to-wp-query\">An Introduction to WP_Query<\/h2><p>In WordPress, your site&rsquo;s data is stored in a MySQL database. This includes everything from posts, pages, and comments, to your configuration settings.<\/p><p>When a visitor clicks on your website, this sends a request to your <a href=\"\/ng\/tutorials\/wordpress-database\">WordPress database<\/a>.<\/p><p>Your database retrieves specific posts and pages to display them based on this <a href=\"\/ng\/tutorials\/what-is-a-query\">query<\/a>.<\/p><p>As a website owner, you can leverage queries to fetch specific information from your database. Although you can build SQL queries, it isn&rsquo;t the most efficient way to retrieve data. This is where WP_Query comes in.<\/p><p><a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/\" target=\"_blank\" rel=\"noreferrer noopener\">WP_Query<\/a> is a PHP class that you can use to construct queries for your database. In WordPress, this is a built-in class that occurs whenever someone searches your content.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"674\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/public\" alt=\"WordPress hosting search results from Hostinger\" class=\"wp-image-55258\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/22wordpress-hosting22-search-results-from-Hostinger.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>However, implementing a custom WordPress query can enable users to find specific content without searching for it. If you need to render a particular group of posts on the front end of your site, you can easily do this using a WP_Query custom post type.<\/p><p>For example, you might want to create a <a href=\"\/ng\/tutorials\/wordpress-custom-post-types\">WordPress custom post type<\/a>. To display these posts, you can write a specific query. Here&rsquo;s the basic <a href=\"https:\/\/gist.github.com\/alexander-young\/d4e7fa6c9e6ffa9a9ea37219be83c8f8\" target=\"_blank\" rel=\"noreferrer noopener\">code structure<\/a> you can use:<\/p><pre class=\"wp-block-preformatted\">\/\/ WP QUERY\n$query = new WP_Query([\n'post_type' =&gt; 'press-release'\n\"posts_per_page =&gt; 25,\n'category_name' =&gt; 'health',\n]);<\/pre><p>This works by customizing <a href=\"https:\/\/codex.wordpress.org\/The_Loop\" target=\"_blank\" rel=\"noreferrer noopener\">the Loop<\/a>. Essentially, the Loop is PHP code that WordPress uses to display certain posts. WordPress knows how to process and format each post based on specified criteria in your WP_Query custom post type.<\/p><p>WP_Query is also helpful for developers. You can customize WordPress themes using this PHP class without directly querying the database.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-use-wordpress-wp-query-4-ways\">How to Use WordPress WP_Query (4 Ways)<\/h2><p>Now that you know about WP_Query, let&rsquo;s discuss how to create your first query. This way, you can quickly and easily customize your website display!<\/p><h3 class=\"wp-block-heading\" id=\"h-1-create-a-loop\">1. Create a Loop<\/h3><p>You&rsquo;ll need to be familiar with the WordPress Loop to get started. As we mentioned earlier, the Loop is responsible for extracting post data from the database. It determines how your content is displayed according to your theme&rsquo;s template files.<\/p><p>Based on the parameters you set, here&rsquo;s what the Loop can display:<\/p><ul class=\"wp-block-list\">\n<li>Content from WordPress custom post types and custom fields.<\/li>\n\n\n\n<li>Post titles and excerpts on your homepage.<\/li>\n\n\n\n<li>A single post&rsquo;s content and comments.<\/li>\n\n\n\n<li>Individual page content using template tags.<\/li>\n<\/ul><p>Before customizing the Loop with WP_Query, you&rsquo;ll need to know the Loop structure. Here&rsquo;s an example of a <a href=\"https:\/\/developer.wordpress.org\/themes\/basics\/the-loop\/#the-loop-in-detail\" target=\"_blank\" rel=\"noreferrer noopener\">basic loop<\/a>:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\nif ( have_posts() ) :\r\n    while ( have_posts() ) : the_post();\r\n        \/\/ Display post content\r\n    endwhile;\r\nendif;\r\n?&gt;<\/pre><p>Let&rsquo;s break down the individual parts of this loop. First, the function have_posts() will check to see if there are posts on your site. If so, the while condition continues the loop for every post. Essentially, this informs your database to display any posts on your website.<\/p><p>However, you might not want to display all your posts. By inserting <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#standard-loop\" target=\"_blank\" rel=\"noreferrer noopener\">WP_Query code<\/a> into the Loop, you can enable WordPress to only render certain posts:<\/p><pre class=\"wp-block-preformatted\">?php\r\n\/\/ The Query\r\n$the_query = new WP_Query( $args );\r\n\/\/ The Loop\r\nif ( $the_query-&gt;have_posts() ) {\r\n    echo '&lt;ul&gt;';\r\n    while ( $the_query-&gt;have_posts() ) {\r\n        $the_query-&gt;the_post();\r\n        echo '&lt;li&gt;' . get_the_title() . '&lt;\/li&gt;';\r\n    }\r\n    echo '&lt;\/ul&gt;';\r\n} else {\r\n    \/\/ no posts found\r\n}\r\n\/* Restore original Post Data *\/\r\nwp_reset_postdata();<\/pre><p>This contains the same basic Loop structure as <strong>if<\/strong> or <strong>while<\/strong> statements. However, there is an additional string of WP_Query.<\/p><p>You can customize the Loop to only display posts associated with a specific <a href=\"\/ng\/tutorials\/wordpress-taxonomy\/\">WordPress taxonomy<\/a>, category, or author based on your set parameters. You could also narrow results by date, tags, custom fields, and more. In other words, when it comes to customizing the Loop with WP_Query, there are many routes you can take.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-use-arguments\">2. Use Arguments<\/h3><p>When you structure your WP_Query, you need to include four basic elements:<\/p><ul class=\"wp-block-list\">\n<li>Query argument<\/li>\n\n\n\n<li>Query itself<\/li>\n\n\n\n<li>The Loop<\/li>\n\n\n\n<li>Post data reset<\/li>\n<\/ul><p>One of the most critical parts of your query is the argument (known as WP_Query args). The argument informs WordPress what data you want to retrieve from the database. Instead of displaying all of your post content, the argument will place some conditions on your loop.<\/p><p>You probably noticed the ($args) line in the previous example. This is where you&rsquo;ll include your query argument.<\/p><p>To <a href=\"https:\/\/code.tutsplus.com\/tutorials\/wp_query-arguments-categories-and-tags--cms-23070\" target=\"_blank\" rel=\"noreferrer noopener\">structure your WP_Query args<\/a>, you&rsquo;ll need to place certain parameters in an array. We&rsquo;ll discuss parameters in the next section, but here&rsquo;s how a basic argument looks:<\/p><pre class=\"wp-block-preformatted\">$args = array(\n    'parameter1' =&gt; 'value',\n    'parameter2' =&gt; 'value',\n    'parameter3' =&gt; 'value'\n);<\/pre><p>For example, if you want to display posts that have a <strong>&lsquo;cooking&rsquo;<\/strong> tag, this is how you can code your argument:<\/p><pre class=\"wp-block-preformatted\">$query = new WP_Query( array( 'tag' =&gt; 'cooking' ) );<\/pre><p>If you don&rsquo;t include a WP_Query arg, this won&rsquo;t pull any content from your database. Without this information, WordPress won&rsquo;t know which posts to display.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-set-parameters\">3. Set Parameters<\/h3><p>As we mentioned earlier, setting parameters is important for customizing WP_Query. You can enable WordPress to retrieve a custom collection of posts from your database by specifying this information.<\/p><p>If you&rsquo;re unsure which parameters to include in your argument, WordPress provides examples for many different uses. Since these are already coded for you, this can save you time and effort when building your WP_Query.<\/p><p>Here are some <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#parameters\" target=\"_blank\" rel=\"noreferrer noopener\">common parameters<\/a> you can use:<\/p><ul class=\"wp-block-list\">\n<li><strong>Posts_per_page<\/strong> &ndash; sets the number of posts that you want to display.<\/li>\n\n\n\n<li><strong>Author<\/strong> &ndash; narrows down the results by one or more authors.<\/li>\n\n\n\n<li><strong>Cat<\/strong> &ndash; specifies the categories that results should fall under.<\/li>\n\n\n\n<li><strong>Tag<\/strong> &ndash; pulls posts that have specific tags.<\/li>\n\n\n\n<li><strong>Orderby<\/strong> &ndash; sorts results by author, post type, date, etc.<\/li>\n\n\n\n<li><strong>Order<\/strong> &ndash; sorts results in ascending or descending order.<\/li>\n\n\n\n<li><strong>Post_type<\/strong> &ndash; defines whether the query should retrieve posts, pages, or custom post types.<\/li>\n\n\n\n<li><strong>Post_status<\/strong> &ndash; specifies if posts are in-progress, scheduled, published, or deleted.<\/li>\n<\/ul><p>For example, you might need to display posts from a <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#category-parameters\" target=\"_blank\" rel=\"noreferrer noopener\">certain category<\/a>. In this case, you can include the category name and slug:<\/p><pre class=\"wp-block-preformatted\">$query = new WP_Query( array( 'category_name' =&gt; 'staff' ) );<\/pre><p>This will pull posts under this WP_Query category and any children of this category.<\/p><p>Using different parameters, you can also show posts from a <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#date-parameters\" target=\"_blank\" rel=\"noreferrer noopener\">specific date<\/a>. For displaying content from 9 AM to 5 PM on weekdays, this is the parameter you would use:<\/p><pre class=\"wp-block-preformatted\">$args = array(\n    'date_query' =&gt; array(\n        array(\n            'hour'  \t=&gt; 9,\n            'compare'   =&gt; '&gt;=',\n        ),\n        array(\n            'hour'  \t=&gt; 17,\n            'compare'   =&gt; '&lt;=',\n        ),\n        array(\n            'dayofweek' =&gt; array( 2, 6 ),\n            'compare'   =&gt; 'BETWEEN',\n        ),\n    ),\n    'posts_per_page' =&gt; -1,\n);\n$query = new WP_Query( $args );<\/pre><p>The number of parameters you can use is practically limitless. By including these custom conditions in your arguments, your WP_Query can successfully present the correct data.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-modify-class-properties-with-methods\">4. Modify Class Properties With Methods<\/h3><p>Since WP_Query is a PHP class, it contains <a href=\"https:\/\/www.php.net\/manual\/en\/language.oop5.constants.php\" target=\"_blank\" rel=\"noreferrer noopener\">constants<\/a> called properties. These are variables for the PHP class.<\/p><p>The developers at WordPress recommend not to alter WP_Query properties directly. However, you can use <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#methods\" target=\"_blank\" rel=\"noreferrer noopener\">methods<\/a> to interact with them.<\/p><p>Methods work similarly to functions. When you modify the methods of WP_Query, you can customize the data that is retrieved.<\/p><p>In the documentation for WP_Query, there are many listed <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/#methods\" target=\"_blank\" rel=\"noreferrer noopener\">functions for basic tasks<\/a>. For example, including a reset_postdata() function can be an important step in writing your WP_Query. This method will reset the properties for $current_post and $post.<\/p><p>Here&rsquo;s what that might look like:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\n\/\/ the query\r\n$the_query = new WP_Query( $args ); ?&gt;\r\n \r\n&lt;?php if ( $the_query-&gt;have_posts() ) : ?&gt;\r\n \r\n    &lt;!-- pagination here --&gt;\r\n \r\n    &lt;!-- the loop --&gt;\r\n    &lt;?php while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); ?&gt;\r\n        &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;\/h2&gt;\r\n    &lt;?php endwhile; ?&gt;\r\n    &lt;!-- end of the loop --&gt;\r\n \r\n    &lt;!-- pagination here --&gt;\r\n \r\n    &lt;?php wp_reset_postdata(); ?&gt;\r\n \r\n&lt;?php else : ?&gt;\r\n    &lt;p&gt;&lt;?php _e( 'Sorry, no posts matched your criteria.' ); ?&gt;&lt;\/p&gt;\r\n&lt;?php endif; ?&gt;<\/pre><p>Ultimately, you&rsquo;ll have to use this method if you use the_post() function in your query. This ensures that the template tags use the main query&rsquo;s current post.<\/p><p>Here are some additional methods you can use to modify your WP_Query properties:<\/p><ul class=\"wp-block-list\">\n<li><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">get_posts<\/code> &ndash; retrieves a post array based on given variables.<\/li>\n\n\n\n<li><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">have_posts<\/code> &ndash; determines whether posts are available in the Loop.<\/li>\n\n\n\n<li><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">generate_postdata <\/code>&ndash; displays posts.<\/li>\n\n\n\n<li><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">fill_query_vars <\/code>&ndash; completes the query variables not listed in the parameters.<\/li>\n<\/ul><p>Based on the information you provide, you can customize your WP_Query to perform the needed function. This can be a flexible, safe way to modify class properties.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-wordpress-hosting\" href=\"\/ng\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"600\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/public\" alt=\"\" class=\"wp-image-111781\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-examples-of-wp-query\">Examples of WP_Query<\/h2><p>Once you learn the basics of WordPress WP_Query, you can start using it to customize your website design. Since there are various parameters you can define, the options are almost endless.<\/p><p>Let&rsquo;s discuss some common examples of WP_Query to give you some inspiration!<\/p><h3 class=\"wp-block-heading\" id=\"h-1-latest-posts-in-a-certain-category\">1. Latest Posts in a Certain Category<\/h3><p>Generally, online users are most interested in new content. After visitors read one of your posts, you&rsquo;ll want to provide some related content. By recommending more recent posts, you can direct users to other content they might enjoy. <\/p><p>There are a few ways to learn how to add <a href=\"\/ng\/tutorials\/how-to-add-wordpress-related-posts\">WordPress related posts<\/a> together, and with this WP_Query can be especially useful for websites that have time-sensitive posts. For example, visitors might read a scientific article on memory loss. Using WP_Query, you can highlight similar topics with up-to-date research:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"556\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/public\" alt=\"An example of using WP_Query to recommend to the reader other articles regarding memory loss\" class=\"wp-image-55259\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-recommend-to-the-reader-other-articles-regarding-memory-loss.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>If you want to pull the latest posts in a specific category, paste this WP_Query:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\n \r\n\/\/ Get the current post id.\r\n$current_post_id = get_the_ID();\r\n \r\n\/\/ Get the current post's category (first one if there's more than one).\r\n$current_post_cats = get_the_category();\r\n$current_post_first_cat_id = $current_post_cats[ 0 ]-&gt;term_id;\r\n \r\n\/\/ Setup arguments.\r\n$args = array(\r\n    \/\/ Get category's posts.\r\n    'cat' =&gt; $current_post_first_cat_id,\r\n    \/\/ Exclude current post.\r\n    'post__not_in' =&gt; array( $current_post_id )\r\n);\r\n \r\n\/\/ Instantiate new query instance.\r\n$my_query = new WP_Query( $args );\r\n \r\n?&gt;<\/pre><p>After editing this query with your site&rsquo;s information, you can display similar posts to the one a visitor just read. This can effectively guide the user to relevant, current information without searching for it.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-posts-published-this-week\">2. Posts Published This Week<\/h3><p>If you have a dedicated following, readers will want to read your newest articles as soon as they&rsquo;re published. When you can design your website to feature recent posts, you can provide the most relevant information.<\/p><p>Especially if you host a news site, you&rsquo;ll need to format your posts from newest to oldest. Doing this can enable users to quickly and easily find time-sensitive content.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"837\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/public\" alt=\"An example of using WP_Query to sort news outlet posts by date\" class=\"wp-image-55260\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-sort-news-outlet-posts-by-date.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Using WP_Query, you can set parameters based on an article&rsquo;s date. By only retrieving posts published in the past week, you can prevent users from seeing out-of-date articles:<\/p><pre class=\"wp-block-preformatted\">&lt;?php  \r\n   $arguments = array(\r\n      \"date_query\" =&gt; array(\r\n         array(\r\n           \"year\" =&gt; date( \"Y\" ),\r\n           \"week\" =&gt; date( \"W\" ),\r\n         )\r\n      )\r\n   );\r\n   $posts = new WP_Query($arguments);\r\n?&gt;<\/pre><p>When you customize the <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">date_query<\/code> parameter, you can target posts published recently. Although you can include your own custom values, it can be effective to highlight articles written in the past week.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-popular-posts-by-comment-count\">3. Popular Posts by Comment Count<\/h3><p>Similarly, you can promote posts that most of your audience enjoyed. By informing users that another post received a lot of engagement, it can encourage them to click on the post to find out more.<\/p><p>Since WordPress doesn&rsquo;t keep track of your post view count, you&rsquo;ll likely need to add this functionality yourself. You can do this with a plugin, but this can slow down your site.<\/p><p>With WP_Query, you can suggest other popular posts according to their number of comments. This makes it easy to display your most well-liked articles:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"480\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/public\" alt=\"An example of using WP_Query to display the most-commented posts next to an open article\" class=\"wp-image-55261\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-the-most-commented-posts-next-to-an-open-article.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>Here is the data you can use to structure your recommendations based on popularity:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\n \r\n\/\/ Setup arguments.\r\n$args = array(\r\n    \/\/ Order by comment count.\r\n    'orderby' =&gt; 'comment_count'\r\n);\r\n \r\n\/\/ Instantiate new query instance.\r\n$my_query = new WP_Query( $args );\r\n \r\n?&gt;<\/pre><p>You can also narrow down these results based on a certain category. Simply add a parameter with your category name:<\/p><pre class=\"wp-block-preformatted\">&lt;?php  \r\n   $arguments = array(\r\n      \"category_name\" =&gt; \"fiction\",\r\n      \"orderby\" =&gt; \"comment_count\",\r\n      \"posts_per_page\" =&gt; 5,\r\n   );\r\n   $posts = new WP_Query($arguments);\r\n?&gt;<\/pre><p>This will also limit the recommendations to five posts. If needed, you can edit this value with a different number.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-posts-by-the-same-author-and-category\">4. Posts by the Same Author and Category<\/h3><p>When visitors read your blog post, they may really enjoy that content. They might simply prefer the author&rsquo;s writing style or the general topic.<\/p><p>In this case, you can use WP_Query to offer similar post recommendations. This way, readers can click on additional articles to continue reading:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"490\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/public\" alt=\"An example of using WP_Query to display posts written by a specific author\" class=\"wp-image-55262\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-posts-written-by-a-specific-author.png\/w=1536,fit=scale-down 1536w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>To build a row of similar posts, you&rsquo;ll need to implement a specific WP_Query string. This will search for blog posts on your website that have the same author and post category.<\/p><p>Here is the code you can use:<\/p><pre class=\"wp-block-preformatted\">&lt;?php  \r\n   $arguments = array(\r\n      \"author_name\" =&gt; \"john\",\r\n      \"category_name\" =&gt; \"fiction\",\r\n      \"posts_per_page\" =&gt; 3,\r\n   );\r\n   $posts = new WP_Query($arguments);\r\n?&gt;<\/pre><p>When implementing this code, you&rsquo;ll want to replace <strong>&lsquo;john&rsquo;<\/strong> with the author&rsquo;s name. Then, remove <strong>&lsquo;fiction&rsquo;<\/strong> and include your category&rsquo;s label. Finally, feel free to modify the number of post recommendations displayed on the page.<\/p><h3 class=\"wp-block-heading\" id=\"h-5-author-s-yearly-posts\">5. Author&rsquo;s Yearly Posts<\/h3><p>If you run a more prominent blog, you likely have many different authors who write posts. After someone reads one of your posts, they might want to find additional posts by that author more easily.<\/p><p>In this case, you can list an author&rsquo;s posts from the past year. This can give visitors information about the author and a list of their previous writing:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"754\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\/public\" alt=\"An example of using WP_Query to display a specific author's yearly contributions\" class=\"wp-image-55263\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/05\/An-example-of-using-WP_Query-to-display-a-specific-authors-yearly-contributions.png\/w=768,fit=scale-down 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>To develop a list of an author&rsquo;s yearly posts, you can use this WP_Query:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\n \r\n\/\/ Get the year we're in.\r\n$current_year = date( 'Y' );\r\n \r\n\/\/ Setup arguments.\r\n$args = array(\r\n    \/\/ Get the author with the nicename \"john\".\r\n    'author' =&gt; 'john',\r\n    \/\/ Get his posts from this year.\r\n    'year'   =&gt; $current_year\r\n);\r\n \r\n\/\/ Instantiate new query instance.\r\n$my_query = new WP_Query( $args );\r\n \r\n?&gt;<\/pre><p>This data will pull all the posts written by a specific author. It will also refine these results based on the current year. For instance, it won&rsquo;t list any articles published over a year ago.<\/p><h3 class=\"wp-block-heading\" id=\"h-6-preview-scheduled-posts\">6. Preview Scheduled Posts<\/h3><p>To give your audience a sneak peek of upcoming content, you can <a href=\"https:\/\/code.tutsplus.com\/tutorials\/mastering-wp_query-10-useful-examples--cms-22980\" target=\"_blank\" rel=\"noreferrer noopener\">list your scheduled posts<\/a> on your website. Using WP_Query, you can display the title and excerpts of your new posts.<\/p><p>This can help generate interest in your articles before you release them. Plus, it&rsquo;s easy to implement with WP_Query:<\/p><pre class=\"wp-block-preformatted\">&lt;?php\r\n \r\n\/*\r\n * Usage with Excerpts:\r\n *\r\n * &lt;?php echo tutsplus_show_drafts(); ?&gt;\r\n *\r\n * Usage without Excerpts:\r\n *\r\n * &lt;?php echo tutsplus_show_drafts( false ); ?&gt;\r\n *\/\r\n \r\nfunction tutsplus_show_drafts( $show_excerpts = true ) {\r\n \r\n    \/\/ Setup arguments.\r\n    $args = array(\r\n        'post_status' =&gt; 'future',\r\n        'nopaging' =&gt; true\r\n    );\r\n \r\n    \/\/ Instantiate new query instance.\r\n    $my_query = new WP_Query( $args );\r\n \r\n    \/\/ Check that we have query results.\r\n    if ( $my_query-&gt;have_posts() ) {\r\n \r\n        \/\/ Begin generating markup.\r\n        $output = '&lt;section class=\"pending-posts\"&gt;';\r\n \r\n        \/\/ Start looping over the query results.\r\n        while ( $my_query-&gt;have_posts() ) {\r\n \r\n            $my_query-&gt;the_post();\r\n \r\n            \/\/ Output draft post title and excerpt (if enabled).\r\n            $output .= '&lt;div class=\"pending\"&gt;';\r\n                $output .= '&lt;h3 class=\"pending-title\"&gt;' . get_the_title() . '&lt;\/h3&gt;';\r\n                    $output .= get_the_title();\r\n                $output .= '&lt;\/h3&gt;';\r\n \r\n                if ( $show_excerpts ) {\r\n \r\n                    $output .= '&lt;div class=\"pending-excerpt\"&gt;';\r\n                        $output .= get_the_excerpt();\r\n                    $output .= '&lt;\/div&gt;';\r\n \r\n                }\r\n \r\n            $output .= '&lt;\/div&gt;';\r\n \r\n        }\r\n \r\n        \/\/ End generating markup.\r\n        $output .= '&lt;\/section&gt;';\r\n \r\n    } else {\r\n \r\n        \/\/ Let user know that nothing was found.\r\n        $output = '&lt;section class=\"drafts-error\"&gt;';\r\n            $output .= '&lt;p&gt;' . __( 'Nothing found', 'tutsplus' ) . '&lt;\/p&gt;';\r\n        $output .= '&lt;\/section&gt;';\r\n \r\n    }\r\n \r\n    wp_reset_postdata();\r\n \r\n    return $output;\r\n \r\n}\r\n \r\n?&gt;<\/pre><p>This will automatically set up a preview of your scheduled post titles. You can also include an excerpt if needed.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p><strong>WP_Query<\/strong> provides a simpler way to perform WordPress database requests. Using this PHP class, you can customize your site&rsquo;s display and offer a unique experience for each online visitor.<\/p><p>Here are the four ways you can use WP_Query in WordPress:<\/p><ol class=\"wp-block-list\">\n<li>Create a loop.<\/li>\n\n\n\n<li>Use query arguments.<\/li>\n\n\n\n<li>Set specific parameters.<\/li>\n\n\n\n<li>Modify class properties.<\/li>\n<\/ol><p>When you&rsquo;ll get the hang of these WordPress WP_Query techniques, you will be able to recommend specific posts based on popularity, date, author, and more.<\/p><p>If you have any more questions regarding WP_Query, feel free to leave a comment down below. Make sure to use reliable <a href=\"\/ng\/wordpress-hosting\">WordPress hosting<\/a> for top-notch site performance. <\/p><p><div class=\"protip\">\n                    <h4 class=\"title\">Learn More WordPress Techniques<\/h4>\n                    <p><a href=\"\/ng\/tutorials\/wordpress\">Complete WordPress Guide<\/a><br>\n<a href=\"\/ng\/tutorials\/how-to-perform-search-and-replace-in-wordpress-database\/\">How to Perform a WordPress Search and Replace in the Database<\/a><br>\n<a href=\"\/ng\/tutorials\/wordpress\/how-to-change-wordpress-urls-in-mysql-database-using-phpmyadmin\">How to Change WordPress URL in Database: A MySQL Tutorial Using phpMyAdmin<\/a><br>\n<a href=\"\/ng\/tutorials\/headless-wordpress\">A Quick Guide to Headless WordPress<\/a><br>\n<a href=\"\/ng\/tutorials\/create-default-wordpress-htaccess-file\">How to Locate and Create the WordPress .htaccess File on cPanel and hPanel<\/a><br>\n<a href=\"\/ng\/tutorials\/wordpress-get-posts-function\">What Is the WordPress get_posts Function and How to Use It<\/a><\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-wordpress-wp-query-faq\">WordPress WP_Query FAQ<\/h2><p>The following are more information on WordPress WP_Query.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1678185562266\"><h3 class=\"schema-faq-question\">What Is WP_Query in WordPress?<\/h3> <p class=\"schema-faq-answer\">WP_Query is a class in WordPress that enables developers to query the database for posts, pages, and attachments. It can also query for other content types based on various parameters, such as category, date, author, and custom fields.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1678185579040\"><h3 class=\"schema-faq-question\">What Is the Difference Between WP_Query and the WordPress Loop?<\/h3> <p class=\"schema-faq-answer\">WP_Query is used to fetch and retrieve posts from the database based on specific parameters, while the WordPress Loop is used to display those posts in a specific format on the front-end of the site. The Loop uses WP_Query behind the scenes to retrieve the posts.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1678185619946\"><h3 class=\"schema-faq-question\">What Are the Benefits of Using WP_Query?<\/h3> <p class=\"schema-faq-answer\">Benefits of using WP_Query include the ability to retrieve and display specific content based on various parameters, such as post type, category, date, and custom fields, allowing developers to create custom queries and display content in a highly flexible and customizable way.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>By default, WordPress automatically sorts your posts from newest to oldest. Although visitors can search for specific posts using categories and tags, they might not be able to find the content they&rsquo;re looking for. To curate your posts for each visitor, it can be helpful to use WordPress WP_Query. Using WP_Query, you can customize the [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ng\/tutorials\/wordpress-wp_query\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":76,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Use WordPress WP_Query: Basics + Use Cases with Code","rank_math_description":"WordPress WP_Query is a database PHP class in WordPress. Learn how to use it to your advantage. Six use case examples with code included.","rank_math_focus_keyword":"wordpress wp_query","footnotes":""},"categories":[22637],"tags":[],"class_list":["post-55276","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/wordpress-wp_query","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/wp_query","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/wp_query-wordpress","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/wp_query-wordpress","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/wordpress-wp_query","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/basics-of-using-wordpress-wp_query-examples-with-code","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/basics-of-using-wordpress-wp_query-examples-with-code","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/wp_query-wordpress","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/wp_query-wordpress","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/que-es-una-url-8","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/wp_query","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/wordpress-wp_query","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/wordpress-wp_query","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/wordpress-wp_query","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/wordpress-wp_query","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/55276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/users\/76"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/comments?post=55276"}],"version-history":[{"count":29,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/55276\/revisions"}],"predecessor-version":[{"id":144408,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/posts\/55276\/revisions\/144408"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/media?parent=55276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/categories?post=55276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ng\/tutorials\/wp-json\/wp\/v2\/tags?post=55276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}