1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WP question - display a single post from a category on static page

Discussion in 'Blogging' started by j0b0123, May 19, 2010.

  1. j0b0123

    j0b0123 Regular Member

    Joined:
    Oct 30, 2009
    Messages:
    262
    Likes Received:
    218
    Occupation:
    professional trader - stocks, forex, futures
    Location:
    Las Vegas, USA
    Home Page:
    I have a membership website I am building which is a combo of static pages inside WP and live posts.

    I have setup the ability to email post updates to a specific category, which works with no issues.

    Additionally, I have hidden that category (email post cat) from display on the home page, which displays posts from only a few selected categories.

    I would like to get only the last 2 posts that is in that category to display on a static page created in wordpress.

    I have examples of php code to get this done, but WP does not like PHP code inserted into the html section of the page, or I am just not doing it right.

    Here is one version of code, I have others, but none work right.

    Code:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php static $count = 0;
    if ($count == "2") { break; }
    else { ?>
    
    <?php if ( in_category('28') && !is_single() && !is_category() && !is_archive() ) continue; ?>
    
    <div class="post">
    <?php the_content(); ?>
    </div>
    
    <?php $count++; } ?>
    <?php endwhile; ?>
    <?php endif; ?>
    Literally all I want is a way to display information that is updated via email but is not displayed in the main blog postings. I know how to restrict the page it would be on. There is only a single category. It can be an internal page OR a page that is linked to, I just cannot figure it out.

    Thanks for any help