ThemeShaper Forums » Thematic

[closed]

Posts on a page.

(7 posts)
  • Started 3 years ago by driftwood
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. driftwood
    Member

    Hey Folks I have a page called Journal that I would like to filter all my posts from a specific post category.

    I created a function but am not sure how to do it. I tried get_post etc but just does not work. Any help?

    function JournalPage() {

    if(is_page("Journal")) {

    }

    }
    add_filter('the_content', 'JournalPage');

    Posted 3 years ago #
  2. if its a page, you need to use a template. set the page template in wp admin.
    thematic comes boxed with a 'blog template' you just need to ammend that to select the query you require (the category).
    Below is the code that makes up the blog template

    <?php
    /**
     * Template Name: Blog
     *
     * This template allows you to display the latest posts on any page of the site.
     *
     */
    
        // calling the header.php
        get_header();
    
        // action hook for placing content above #container
        thematic_abovecontainer();
    
    ?>
    
    		<div id="container">
    
    			<?php thematic_abovecontent();
    
    			echo apply_filters( 'thematic_open_id_content', '<div id="content">' . "\n" );
    
    			$wp_query = new WP_Query();
    			$wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged ) );
    			$more = 0;
    			?>
    
    				<?php 
    
                	// create the navigation above the content
                	thematic_navigation_above();
    
                	// calling the widget area 'index-top'
                	get_sidebar('index-top');
    
                	// action hook for placing content above the index loop
                	thematic_above_indexloop();
    
                	// action hook creating the index loop
                	thematic_indexloop();
    
                	// action hook for placing content below the index loop
                	thematic_below_indexloop();
    
                	// calling the widget area 'index-bottom'
                	get_sidebar('index-bottom');
    
                	// create the navigation below the content
                	thematic_navigation_below();
    
                	?>
    
    			</div><!-- #content -->
    
    			<?php thematic_belowcontent(); ?> 
    
    		</div><!-- #container -->
    
    <?php 
    
        // action hook for placing content below #container
        thematic_belowcontainer();
    
        // calling the standard sidebar
        thematic_sidebar();
    
        // calling footer.php
        get_footer();
    
    ?>

    in this particular section above

    $wp_query = new WP_Query();
    			$wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => $paged ) );
    			$more = 0;
    			?>

    you need to add to the query array, the category you want displayed.
    http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters

    hope this helps

    Posted 3 years ago #
  3. driftwood
    Member

    Thanks a bunch for your help!!!

    I got it half way working but must be doing something wrong.....

    <?php
    if (is_page(418)) {
    query_posts('category_name=journal' );
    }
    ?>

    I added the above.. and it does not filter. I get all the posts showing. Not sure I am putting this in the right place :(

    Posted 3 years ago #
  4. if i understand correctly, you want a page that only shows posts from the category journal yeah?

    so use the template above. copy all of it into an empty php file and call the file
    template-page-journal.php

    change

    Template Name: Blog

    to

    Template Name: Journal

    set up a new page in wp-admin>pages, and select 'journal' it from page attributes.

    at the top of that template, change this section to reflect the added category..

    $wp_query = new WP_Query();
    			$wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'category_name' => 'journal', 'paged' => $paged ) );
    			$more = 0;

    this should work.
    you dont need those conditional, is page() if you are using the template.
    let me know how you get on

    hope this helps

    Posted 3 years ago #
  5. oh, looking at that again, add the following line

    $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;

    to the above query.
    so in full

    $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
    $wp_query = new WP_Query();
    			$wp_query->query( array( 'posts_per_page' => get_option( 'posts_per_page' ), 'category_name' => 'journal', 'paged' => $paged ) );
    Posted 3 years ago #
  6. driftwood
    Member

    got it, and it works thanks!!!!

    Posted 3 years ago #
  7. excellent. don't forget to mark this thread as resolved.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.