WordPress.org

Support

Support » Miscellaneous » Displaying posts on other parts of site

Displaying posts on other parts of site

  • Hi there,

    Fairly new to this stuff but loving every minute of WP.

    Is it possible to display certain posts on other parts of my site? For example, if WP is here: mysite.com/blog/wordpress/ is it possible to display posts from a certain catagory on the front page here: mysite.com/index.php

    Many thanks for your help,

Viewing 7 replies - 1 through 7 (of 7 total)
  • Short answer, yes.
    Long answer, include this in your header on your index.php at the root install.
    <?php
    require('/pathtoyourwordpressinstall/wp-blog-header.php');
    ?>

    You then should be able then to include the loop within that page.

    Many thanks for your help, although I have no knowledge of PHP (plenty of HTML though) –

    I include the:
    <?php
    require(‘/pathtoyourwordpressinstall/wp-blog-header.php’);
    ?>

    On.. for example /myblog/wordpress/index.php – is that correct?

    And also, how do I create a loop, and where do I place it?

    Thanks again for your help,

    You just include the <?php
    require(‘/pathtoyourwordpressinstall/wp-blog-header.php’);
    ?> in the <head> of the page that you want the posts to apear on. Next, as milkb said you need to call the posts from the loop. All you will ever need to know about the loop can be found here:

    http://codex.wordpress.org/The_Loop

    Cron

    Fantastic!

    I’ve tried it out, even customized parts and it’s working great.

    Thank you very much, to both of you, for your help.

    Oops sorry about this. Trying to change the catagory using the following code, but it displays all the latest posts.. how is this code looking to you? Again, thank you for your help.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category(’11’) ) { ?>
    <div class=”post-cat-eleven”>
    <?php } else { ?>
    <div class=”post”>
    <?php } ?>
    <h2>“><?php the_title(); ?></h2>
    <small><?php the_time(‘F jS, Y’); ?></small>
    <div class=”entry”>
    <?php the_content(); ?>
    </div>
    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘); ?>
    </div>
    <?php endwhile; else: ?>
    Sorry, no posts.
    <?php endif; ?>

    I should also point out that I’m using the /%postname% permalink structure, I’m not sure if this has anything to do with the problem? Many thanks,

    I guess it’s wrong code.
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category('11') ) { ?>
    <div class="post-cat-eleven"> <=== if 11, do what?
    <?php } else { ?>... etc.

    You need to put there what to do if is cat 11. Use the template tags (title, content etc. that you want to be shown there.

    Thank you so much for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Displaying posts on other parts of site’ is closed to new replies.