Display Particular Post/Page in WordPress

WordPress is now widely used in different types of websites. It’s perfect for blogging and a good CMS for company and personal websites.

As a web developer, we should maximize this feature of WordPress. One particular scenario is when the client needs to show an excerpt of a particular article in a page.

A bigger problem will come if he wants you to show 10 articles from different categories. Using a plugin is not advisable at this time. It’s time to face you’re best text editor and start coding.

The key code here is


Display Particular Post outside the Loop

If the article that you need to show in a specific page is a post you can use the code below:

In the code above, the ID of the post that we retrieve is 102.

Display Particular Page outside the Loop

If you need to show a page in a particular space on the web page, use the code below:

The page with 437 ID will show.

As you can see, we use

This is to avoid conflicts on queries. It’s a good practice to always reset the query to avoid confusion on other posts or pages.

This is a very important code if you’re retrieving more than one particular article in a single page.

Complete Code Example

Where to Find the ID of the Post/Page?

The ID will show above the windows task bar when you hover the title of the article. Works on Mozilla and Chrome

You can see the ID in the URL when you edit the page