WP: Is there a way to automatically update a page with category posts?

4 replies
  • |
In WP, let's say I create a category called "Articles" and make, obviously, POSTS that are articles.

Is there a way to AUTOMATICALLY update a PAGE called "Articles" as well with the links to the new posts in the category?

#automatically #category #page #posts #update
  • Profile picture of the author soffell
    I think you need to change .php code from theme editor, try in your local computer ir's better
    Banner Ads For Your MAX advertising
    {{ DiscussionBoard.errors[1172134].message }}
  • Profile picture of the author Jay Rhome
    I'm pretty sure too it has to be about adding some PHP code but what code, and how to apply it only to one page, that's what I'm not sure how to do.
    {{ DiscussionBoard.errors[1172648].message }}
  • Profile picture of the author zargonoth
    Are you using a CMS like wordpress or Joomla? If so, its easier to edit the database (back it up first.)

    If it's static html or dynamic php, then yes you could edit the code.
    If it's a small site, you could use notepad++ (windows) to open all of the pages at once and make a "find/replace" command across all open pages. that's pretty painless.
    {{ DiscussionBoard.errors[1172674].message }}
    • Profile picture of the author CGM
      Heres the code you'll need. In page.php you'll first have to check to see if your on the articles page, then display all the posts of the articles category

      Create a blank page first called articles or whatever you want.

      In page.php place this code where you want.

      if (($pos = strpos($_SERVER["REQUEST_URI"], 'articles/')) !== false) {

      //The Query
      $temp = $wp_query;
      $wp_query= null;
      $wp_query = new WP_Query();

      $wp_query->query('cat=3'); //CHANGE THIS NUMBER TO THE CATEGORY ID!!!!!!!!!!!!!
      global $more;
      $more = 0;

      if ( $wp_query->have_posts() ) :
      while ( $wp_query->have_posts() ) : $wp_query->the_post();
      <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
      <?php the_content('(read more...)'); ?>

      //Reset Query
      $wp_query = null;
      $wp_query = $temp;

      Good luck.
      {{ DiscussionBoard.errors[1172987].message }}

Trending Topics