Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15811
    monolith
    Member

    Hello.

    I want to add a loop to 2 static pages on my site. I am putting in the PHP, and it’s not doing what I want. I want to display all my posts that are categorized under ‘READ’ on one page, the category ‘LISTEN’ will be on another. The Category ID for READ is 3. This is the code I have, why is it not working?

    <?php
    query_posts( ‘category_name=READ&posts_per_page=10’ );
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category(‘3’) ) {?>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>
    <small><?php the_time(‘F jS, Y’) ?> by <?php the_author_posts_link() ?></small>
    <div class=”entry”>
    <?php the_content(); ?>
    </div>
    <?php endwhile; else: ?>
    <p>No Posts</p>
    <?php endif; ?>

    I only want posts, there is no static content on these pages. Currently, I am getting all my posts on this page, not just the ones specified. Also in settings, I have left my posts page blank.

    #15833
    Sakin
    Keymaster

    @monolith: This is customization and for then you need to hire developer.

    I will guide you on how you can do it.

    First, you need to create Child Theme of Catch Everest and then create two new page templates. You can just copy page-blog.php from Catch Everest theme and then create similar 2 templates. For example: page-listen.php and page-read.php files. In these two new files, you need to change then template name from Template Name: Blog to the name you want it to be recognized with.

    Then in WP_Query array add category__in => 3 for your page-read.php file.
    For Child theme, read here http://codex.wordpress.org/Child_Themes
    For WP_QUERY, read here http://codex.wordpress.org/Class_Reference/WP_Query

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Adding a loop to my static pages.’ is closed to new replies.