• Resolved spoofm0nkey

    (@spoofm0nkey)


    Does anyone know ANY method to include posts from a category onto a page-type page? So you can just click a page, and just the top part is the page text, and then all the category posts are displayed next.

    I’ve tried the one or two plugins that even resemble what I’m trying to do and they’re bad. I also tried using a php-exec plugin to try to include posts through the regular php but it didn’t work out just because I could figure out how to limit the_post code to a specific category.

Viewing 6 replies - 1 through 6 (of 6 total)
  • hi

    There aere better ways to do it than the way you are thinking of it.
    Make a custom page template for that page
    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    in the PHP for that template first include the regular WP loop code to bring in the page content.

    then include a custom post query to bring in the category posts. see this article
    http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/

    Thread Starter spoofm0nkey

    (@spoofm0nkey)

    It turns out the theme I’m using had this “blog” template…so I tried using that, I figured it would take posts out of the blog category but it didn’t work out.

    So, it displays posts on a page, that’s good. But I don’t know how to specify the category it displays posts from.

    In the blog.php file:

    <?php
    			$wp_query = new WP_Query();
    			$wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged ) );
    			$more = 0;
    		?>
    
    		<?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    
    			<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    
    				<?php hybrid_before_entry(); // Before entry hook ?>
    
    				<div class="entry-content entry">
    					<?php the_content( sprintf( __('Continue reading %1$s', 'hybrid'), the_title( ' "', '"', false ) ) ); ?>
    					<?php wp_link_pages( array( 'before' => '<p class="pages">' . __('Pages:', 'hybrid'), 'after' => '</p>' ) ); ?>
    				</div><!-- .entry-content -->
    
    				<?php hybrid_after_entry(); // After entry hook ?>
    
    			</div><!-- .hentry .post -->
    
    			<?php endwhile; ?>
    
    			<?php hybrid_after_page(); // After page hook ?>

    Read over http://codex.wordpress.org/The_Loop and that should help you.

    Thread Starter spoofm0nkey

    (@spoofm0nkey)

    I read over it, thanks. I used the conditional to do it, and it sort of works.

    <?php if (in_category(’10’)) { ?>
    blah blah post stuff
    <?php }; ?>

    Now, it displays only posts from the blog category (yay), the only problem is, the post is on the second page.
    http://astrocomical.com/blog/

    Before I limited it to only that category, every category post was listed, and the blog one happened to be on the second page. Now it’s staying there for some reason, instead of moving up.

    Thread Starter spoofm0nkey

    (@spoofm0nkey)

    Any other methods to specify a category?

    Thread Starter spoofm0nkey

    (@spoofm0nkey)

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I include posts on a page?’ is closed to new replies.