• On a blog page, I have a few sticky posts. However, every time I upload a new post, I want it to show on the top of the page, like a feature post. How can I do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Use a loop like:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Featured Post';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter Jam

    (@pimaniii)

    Hmm… Where should I place that? I tried putting it in page.php and replacing it with

    if (have_posts()):
             while (have_posts()):
              the_post();
              mystique_page();
             endwhile;

    But nothing changed.

    Put that in whatever template is displaying your posts.

    Review:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    Thread Starter Jam

    (@pimaniii)

    Ok, I placed it in Index.php and it worked.

    However, that code only displays a link to the post.

    Is there any way I can display the entire/part of the post, and have it identify as a feature post? Also, I am using Mistique, so how can I make it look like the other posts? I know this is a specific question, so if someone could point me in the right direction that would be great!

    Specific code is nicer! =]

    Thanks

    Put the template tag, the_content(), or [Template_Tags/the_excerpt|the_excerpt()]], just before the endwhile.

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Feature Post?’ is closed to new replies.