Wordpress display news in a page

Soldato
Joined
9 Jun 2006
Posts
4,227
Location
Purgatory
Hi everyone,
I am currently developing a website. I have little knowledge of php and so am asking for your help.


Please first take a look at this site design draft: http://liquidfirestudios.com/files/lfs4-mock2.jpg


As you can see, I would like to display some other content before displaying the news feed. To do this, I am thinking of using the exex-php plugin (which allows PHP code to be executed in pages and posts). With this plugin activated, I will create a new page with the big image and welcome text, then add the php code that normally display the news.



What I want to know, is what PHP code I need to use to display the news?


Any help would be greatly appreciated :)
 
So you would like 2 areas of content on 1 page?

You can either, just drop the static content in above the WP loop or create a subpage for that page called "Welcome" (or whatever you want) and using the get_children WP function you can call in that page.

It means you can have multiple editable sections on 1 page. So you can have your main loop outputting blog posts, and a sub-page which can be used as the welcome text so you can update it via WP control panel and not going through a text editor.
 
Ok I understand.

This is my index.php page.
As far as I can tell with my limited knowledge, the best place to put my static content would be within the "echo 'Latest posts';" This will make the static content only appear on Latest Posts page, which is what I want. However I would prefer it if the static content had a better position in this code - Maybe a PHP if displaying latest posts then display this static content kind of thing.

Code:
<?php get_header(); ?>

<?php /* this is to deal with author pages */
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name); // NOTE: 2.0 bug requires get_userdatabylogin(get_the_author_login());
else :
$curauth = get_userdata(intval($author));
endif;
?>

<div id="content">
    <?php if (have_posts()) : ?>
        
        <?php if (!is_single() && !is_page()) echo "<h2 class=\"pagetitle\">";
        if (is_home()) {
            echo 'Latest posts';
        } elseif (is_category()) {
            echo 'Posts categorized “' . single_cat_title('', false) . '”';
        } elseif (is_tag()) {
            echo 'Posts tagged  “' . single_tag_title('', false) . '”';
        } elseif (is_author()) {
            echo 'Posts by ' . $curauth->nickname;
        } elseif (is_day()) {
            echo 'Posts from ' . get_the_time('F jS, Y');
        } elseif (is_month()) {
            echo 'Posts from ' . get_the_time('F Y');
        } elseif (is_year()) {
            echo 'Posts from ' . get_the_time('Y');
        } elseif (is_time()) {
            echo 'Posts from a particular time on ' . get_the_time('F, jS, Y');
        } ;
        if (!is_single() && !is_page()) echo "</h2>"; ?>
        
        <?php while (have_posts()) : the_post() ?>
            

        <?php if (is_single() || is_page()) { /* for single-item pages, make that thing big */ ?>
            <h2 class="pagetitle"><?php the_title(); ?></h2>
            
            <div class="post" id="post-<?php the_ID(); ?>">
        <?php } else { /* otherwise, make it small since you'll have one of the headings above */ ?>
            <div class="post" id="post-<?php the_ID(); ?>">
                <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
            <?php } ?>
                <div class="entry">
                    <?php the_content('More... &raquo;'); ?>
                </div>
                
                <?php if (is_single() || is_page()) { ?>
                    <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                <?php } ?>
                
                <p class="postmetadata">Posted by <?php the_author_posts_link(); ?> at <?php the_time('g:i a'); ?> on <?php the_time('F jS, Y')?>. <?php edit_post_link('Edit this post.', '(', ')'); ?> <?php comments_popup_link('No comments... »', 'One comment... »', '% comments... »', 'comments-link', ''); ?><br />
                <?php /* pages don't have categories or tags */ if (!is_page()) { ?> Categories: <?php the_category(', '); ?>. <?php /* } */?>
                <?php if (get_the_tags()) the_tags('Tags: ', ', ', '.'); ?><? } ?></p>
            </div>
        
        <?php comments_template(); ?>
        
        <?php endwhile; ?>
        
        <?php if (!is_single() && !is_page()) { ?>
            <div class="navigation">
                        <div class="goback"><?php next_posts_link('&laquo; Back...'); ?></div>
                        <div class="goforward"><?php previous_posts_link('Forward... &raquo;'); ?></div>
            </div>
        <?php } ?>

    <?php else : ?>

        <h2>Not Found</h2>
        <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif; ?>
</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
 
Back
Top Bottom