Forums

Post content on page with new page template? (10 posts)

  1. GadgetEffect
    Member
    Posted 2 years ago #

    Ok, so I would like to post content on a fresh and new page. The trick is, I want that Content to be posted along with my new template I made. The template would consist of a static content article with blog posts to a specific category underneath. If anyone could help me figure it out, I would greatly appreciate it. Here's the code.

    <?php
    /*
    Template Name: Example Template
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="content">
    
                   <?php include('picturearea.php') ?>
    
                 <h1>Insert static content header here.</h1>
    
                 <div id="entry">
    
                 <p>Insert static content here.</p>
    
                 </div>
    
                 <?php query_posts("category_name=example"); ?>
    
                 <?php while (have_posts()) : the_post(); ?>
    
                   	<h1><?php the_title(); ?></h1>
    
    				<div id="entry">
    
    					<?php the_content(); ?>
    
                    </div>
    
                    	<?php endwhile; ?>
    
    						<div id="navigation">
    			<div id="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div id="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    				</div>
    
      </div> <!-- content -->
    
    <?php get_footer(); ?>
  2. kymac
    Member
    Posted 2 years ago #

    Are you looking for something for your home page? Or is it for a separate page?

    Either way, I think you will want two 'loop's - one for the static (page?) content, and one for the posts in category.

    More information, please.

  3. GadgetEffect
    Member
    Posted 2 years ago #

    I'll be doing it for the home page and separate pages. The loop that I have is for blog posts from each category, I need a loop for when I make a new page.

    Just say I go to 'add new' page and then you see the title and the page content area. I want to choose the right template and then I want to add content and a header to that area so that way it will have the content I add through the page creator and then the extra content that I add later through postings (with the category/post loop).

  4. kymac
    Member
    Posted 2 years ago #

    Sorry, I don't think I can help with that.

  5. GadgetEffect
    Member
    Posted 2 years ago #

    Could you at least tell me what the loop is for posting to a new page through the page creator?

  6. kymac
    Member
    Posted 2 years ago #

    I'm sorry, I don't understand the question. My guess is that what you want is a template for your pages. See http://codex.wordpress.org/Pages, especially the section on 'Page Templates'.

  7. GadgetEffect
    Member
    Posted 2 years ago #

    I think that is what I needed, thank you very much!

  8. kymac
    Member
    Posted 2 years ago #

    You are welcome.

    One minor point - I wouldn't put any content in the template unless it is absolutely necessary. Put it in a post and retrieve the post in the template with a first loop. Then get the other posts in a second loop.

  9. GadgetEffect
    Member
    Posted 2 years ago #

    Ok, maybe you can help me some more. I am trying to use

    <?php query_posts('pagename=example'); ?>

    That is to pull the page content that I mentioned. I didn't know what all pages were called posts too in PHP. So that first loop I can pull, but I don't know how to end the loop and start the second loop without either going in to infinite loops.

    My code is now this

    <?php
    /*
    Template Name: example
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="content">
    
                   <?php include('picturearea.php') ?>
    
                   <?php query_posts('pagename=example'); ?>
    
                 <h1><?php the_title(); ?></h1>
    
                 <div id="entry">
    
                 <?php the_content(); ?>
    
                 </div>
    
                 <?php query_posts("category_name=example"); ?>
    
                 <?php while (have_posts()) : the_post(); ?>
    
                   	<h1><?php the_title(); ?></h1>
    
    				<div id="entry">
    
    					<?php the_content(); ?>
    
                    </div>
    
                    	<?php endwhile; ?>
    
    						<div id="navigation">
    			<div id="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div id="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    				</div>
    
      </div> <!-- content -->
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    
    <?php get_footer(); ?>

    Think you could help me with starting and stopping each loop successfully?

  10. kymac
    Member
    Posted 2 years ago #

    Here is a starting point: http://codex.wordpress.org/The_Loop.

    You should check the WP Codex first for queations, then post here if you can't find an answer.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.