The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress post to right place on theme..

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #202788

    Hi folks,

    i’m new with WP.

    Previously i made Concrete5 sites and themes. Now i’m making my very first WP theme. And now i’m wondering how i get
    RIGHT content (post) for my “Content Areas” in my index.php??

    Should i use ID somehow or what?

    I have uset this loop just to test my page:

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
     <h1><?php the_title(); ?></h1>
     <?php the_content(); ?>
     <?php endwhile; endif; ?>

    but it gives/lists me all the post i got on to specify this that i get just right post to right place in my page???

    Pls, help !

    // Mika

    Ilan Firsov

    Wordpress gives you the option to use WP_Query class to create custom loops. I have not used it myself, but depending on how you structure your data it should allow you to do what you want.

    Example from the docs:
    Display posts tagged with bob, under people custom taxonomy

    $args = array(
        'post_type' => 'post',
        'tax_query' => array(
                'taxonomy' => 'people',
                'field'    => 'slug',
                'terms'    => 'bob',
    $query = new WP_Query( $args );
    // The Loop
    while ( $query->have_posts() ) {
        echo '<li>' . get_the_title() . '</li>';

    I’m not 100% of what you’re asking, but the you can use the WP_Query class as suggested by Ilan for fetching specific posts by tag, category, author, date, etc.

    Also, the index.php markup is a fallback for the theme to go to if specific files are missing. You should look into the WP Hierarchy. This nifty tool will help you understand how and which files WP looks for depending on the part of the site you’re on.

    Last thing, having different page templates will help you organize your theme and are really helpful for child-themes.


Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.