How to Keep My Articles Separate From My Posts on WordPress

104 9

    Edit Your Theme Templates

    • 1). Log in to your WordPress dashboard from the WP-Admin directory of your website. Navigate to "Editor" under "Appearance" to load the "Edit Themes" screen. Click the link for Index.PHP under the "Templates" heading.

    • 2). Find the beginning of your WordPress loop code in the Index.PHP file. The code looks like this:

      <?php if(have_posts()) : while(have_posts()) : the_post(); ?>

      Add a new line above that code and type this:

      <?php query_posts('category_name=post'); ?>

    • 3). Locate the end of your WordPress loop. This code includes at least "endwhile" and "endif" statements, usually with an error-handling message between the two. Below the "endif" statement that closes your loop, add this code:

      <?php wp_reset_query(); ?>

      Click the blue "Update File" button to save your work.

    • 4). Open your Index.PHP file in a code editor or Notepad on your computer. Copy and paste its code into a new file and save it with the file name you want to use. Add a new line to the top of the code in that file and write this:

      <?php /* Template Name: Articles */ ?>

    • 5). Scroll down to the "query_posts()" function and change "post" to "article" for your category name. Save the file and upload it to your theme's folder on your server, which is located under /wp-content/themes/.

    Set Up Your Articles Page and Categories

    • 1). Navigate to "Pages" within the WordPress dashboard, and click "Add New." Fill in the title field with the name "Articles" and select "Articles" under the "Templates" heading on the right side of the screen. Do not add any content in the editor box. Click the blue "Publish" button to create the page.

    • 2). Navigate to "Categories" under "Posts" and fill in the form under "Add New Category" to create a category titled "posts." Create another category titled "articles."

    • 3). Go to "Posts," and hover over the title of a post. Click the "Quick Edit" link that appears and check the box for the appropriate category. Place each post in "posts" or "articles" so your blog index will only display regular posts and the "Articles" page will only display articles.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.