• Resolved mashby

    (@mashby)


    Now that I’ve learned how to create Featured Articles and Blog Posts, I’ve stumbled into another quandary.

    I’d like to create an archive page that lists posts queried by a custom field. For example, I’d like if a viewer goes to http://mydomain.com/articles/ that they see only entries that have the custom field I created (Entry-Type) that have the value of “Articles” to appear in a bulleted list.

    I’m completely befuddled on how to do this. Anyone care to throw me a bone? 🙂

Viewing 1 replies (of 1 total)
  • Thread Starter mashby

    (@mashby)

    Spent some more time digging and luckily came up with the right query in my searches to find an answer to what I was looking for. Here’s how I did it:

    1. In my themes folder, I saved “archives.php” as a new file titled “article-archives.php”

    2. In the article-archives.php template I added changed the template name from “Archives” to “Article Archives”

    3. I created a new page called “Articles” and chose “Article Archives” as the template.

    4. After that, I simply edited the article-archives.php template until it included just the entries tagged “Article” and tweaked the layout a bit. I found the article WordPress Archive that *works*: StepxStep Guide and Plugins very helpful.

    Here’s the final code that I ended up with for my article archives:

    <ul>
       <?php
          query_posts('meta_key=Entry-Type&meta_value=Article&showposts=-1' );
          if (have_posts()) :
             while (have_posts()) : the_post(); $category = get_the_category();
       ?>
       <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>, by <?php the_author(); ?> on <?php the_date(); ?></li>
       <?php
          endwhile;
          endif;
       ?>
    </ul>

    Hope others might find this helpful.

Viewing 1 replies (of 1 total)
  • The topic ‘How Can I Create An Archive By Custom Field’ is closed to new replies.