Forums

[resolved] including a category into a page. (13 posts)

  1. Zaphieonx
    Member
    Posted 3 years ago #

    found a plugin that allows you to include a post into a page by post ID, its called Inline Post... but what i am looking for is actually making a "home page" where a "current events" block will change according to what i post via that category.

    so maybe I could do something as simple as maybe a php include??

  2. MichaelH
    Volunteer
    Posted 3 years ago #

  3. therizone
    Member
    Posted 3 years ago #

    hmm that plugin is pretty nifty, but I'm not sure if that's what Zaphieonx was looking for?

    I am looking for something similar, I want to be able to mod the way the default posts are displayed on the index.php based on what category they are posted in.

    Im not very great at php so I'm not sure if that link you posted can actually do that.

    I had found some code posted a while back like this.

    <?php if (is_category('home')) {
    	query_posts("category_name=home&showposts=3"); ?>
    	<h2>Recent Posts</h2>
    	<ul>
    	<?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
    	</ul>
    <?php } ?>

    I cant seem to get it to work though.. can anybody help?

  4. Zaphieonx
    Member
    Posted 3 years ago #

    neither of those ideas really apply to what I am looking to do. Thanks for the input though.. what i am looking to do is build a front page, most of this info will stay static.. within this page though will be a for lack of better examples Iframe/php include that will print/display post from the "current events" category.

  5. buddha trance
    Member
    Posted 3 years ago #

    @ Michael - yes that tutorial is great for creating loops with some posts in full, some as titles, basically degrading the size of the post. And I think it can be adapted to several other uses, including pulling specific categories. :-)

    @ Zaphieonx + @ therizone - To have a page display one single category, the regular loop way, I have done it by creating a template and using the following

    <?php if(have_posts()) : ?>
    		<?php
       if (is_page()) {
          query_posts("cat=3");
       }
    ?>
    
    <?php while(have_posts()) : the_post(); ?>

    For the home page, I think it would work with

    if (is_home()) instead of if (is_page())

    Of course, you use the appropriate category number for your "current events" category. See it this works for you, unless you need the posts to degrade, or include other loops, as per the link Michael gave you.

  6. therizone
    Member
    Posted 3 years ago #

    buddah trance, thanks mate!

    it worked exactly what i wanted it for..

    ohh thats a relief I tell you,

    @ Zaphieonx, good luck with getting your problem solved!

  7. Zaphieonx
    Member
    Posted 3 years ago #

    well I got it working briefly.. but soon as i went to edit the "home" page, it started ignoring the new template.. actually tested this by changing the page.php file... heres the template file I came up with.

    <?php
    /*
    Template Name: Main
    */
    ?>
    <?php get_header(); ?>
    
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    
    <?php $temp_query = $wp_query; ?>
    <?php query_posts("cat=4&showposts=1"); ?>
    
    <?php while (have_posts()) : the_post(); ?>
      <div class="post" id="post-<?php the_ID(); ?>">
    
      <center><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2></center>
    
     <div class="entry">
       <?php the_content('Read more &raquo;'); ?>
     </div>
    	</div>
    <?php endwhile; ?>
    
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
  8. scottdubose
    Member
    Posted 3 years ago #

    Just wondering if you got that problem solved. I've been trying to do the same thing now for about a month now. Need to get front page(home) to stay static with no post going to it, and the new posts going to the posts page. Is this the same thing you are trying to do?

  9. Zaphieonx
    Member
    Posted 3 years ago #

    scott what your trying to do is done thru..

    Settings > Reading

    Front page displays
    Then just select Static page

    choose which page you wont displaying your as your home page and as your post page..

    ............

    I got my issue fixed I do believe.

  10. scottdubose
    Member
    Posted 3 years ago #

    Ive done that but I still get posts comming up on my front page.

  11. buddha trance
    Member
    Posted 3 years ago #

    @ Zaphieonx - Did you get your issue fixed for good?

    If not, the way I created the page template, was to copy index.php into it (not page.php), put the template name on top, and inserted the posts query.

    Then created a page with a title, and in the attributes I chose that template. That way I had a page pulling a loop with only a specific category.

    This is assuming that you want a page, other than the regular index.php "home page", and then have index.php pull the full loop. Otherwise, simply put the query into index.php

    Hope my description is clear enough :-)

  12. Zaphieonx
    Member
    Posted 3 years ago #

    yes thanks this has been resolved.

  13. timhodson
    Member
    Posted 2 years ago #

    Hi,
    You might find my blog-in-blog plugin to be of use:
    http://wordpress.org/extend/plugins/blog-in-blog/

    Thanks
    Tim

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.