Forums

News and Blog on same site (4 posts)

  1. Chrille
    Member
    Posted 3 years ago #

    Hi,
    My first post :)

    What i want for my site, to be able to write important news on one page and still have a blog page for bladder.

    It should be easiest to sort on a Category, so all Posts with news-category would pop up on News page, and all other Categories on the blog page.

    Since posts dont have template's as pages how would i resolve this?

    Thank you in advance
    /CD

  2. Jim de Groot
    Member
    Posted 3 years ago #

    You could build a page template, for viewing only the news-category posts. In the template code, a database query for news-category posts only should be used.

  3. Chrille
    Member
    Posted 3 years ago #

    Ok, i get that, that should work, but i am not that good at php :/

    How would i query that inside the loop?
    Here is my index.php:

    <div id="content">
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    			    <div class="titleback">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<div class="dateicon"><small><?php the_time('j F Y,') ?> <!-- av <?php the_author() ?> -->i kategorin <?php the_category(', ') ?></small></div>
    				</div>
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata">-<?php the_author() ?> |<!-- Posted in <?php the_category(', ') ?> | --><?php edit_post_link('Edit','',' '); ?> <!-- <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> --><?php if(function_exists('wp_print')) { print_link(); } ?></p>
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Tidigare Nyhet') ?></div>
    			<div class="alignright"><?php previous_posts_link('&nbsp; Nästa Nyhet &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    
    	</div>

    /cd

  4. Jim de Groot
    Member
    Posted 3 years ago #

    Read these articles for more information.
    Category_Templates
    Stepping_Into_Templates
    wpdb_Class

Topic Closed

This topic has been closed to new replies.

About this Topic