Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

thematic page display posts WordPress

  • SOLVED

I am building a wordpress site creating a child theme on thematic. This is the site so far:
http://www.greenfrontiersenergy.com/

I need help with 2 pages, the "people" and "news."

I would like the posts that are in the people category to be displayed on the "people" page and the posts in the press release category to be displayed in the "News" page. I would like the full post to be displayed (not an excerpt) and I dont want the post title to link anywhere.

On the people page, I would like to utilize the thumbnail function to set the profile image.
I do not want the sidebar to appear on the people page.

Attached are jpegs of what I would like the 2 pages to look like.

Please message me if you can work on this for me and let me know what files you need access to.

Thanks

Answers (3)

2010-03-23

Brian Richards answers:

Well, I cannot see your attached images, but I can already tell you that you actually have 2 options. The simplest would be to redirect these pages to their respective categories using either the page-links-to plugin or a page template with a simple http redirect. You can then style the category to appear however you like, thanks to all of the dynamic classes available.

Alternatively, if you have a reason for these pages to remain pages while pulling in the post loop, that is totally possible too. Below is the code you need, create a new file named page_category.php (the name is irrelevant) and paste this into it. I'll explain whats hapening after after:

<?php
/*
Template Name: Display a Category
*/
?>

<?php get_header() ?>

<div id="container">
<div id="content">

<?php get_sidebar('page-top') ?>

<?php the_post() ?>
<div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class() ?>">
<?php thematic_postheader(); ?>
<div class="entry-content">
<?php the_content() ?>
<?php wp_link_pages("\t\t\t\t\t<div class='page-link'>".__('Pages: ', 'thematic'), "</div>\n", 'number'); ?>
<?php edit_post_link(__('Edit', 'thematic'),'<span class="edit-link">','</span>') ?>

<?php
$temp = $wp_query;
$categoryid = ($_GET['cat']) ? $_GET['cat'] : get_post_meta($post->ID, 'categoryid', true);
$showposts = (get_post_meta($post->ID, 'showposts', true)) ? get_post_meta($post->ID, 'showposts', true) : 10;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_query('cat='.$categoryid.'&showposts='.$showposts.'&paged='.$paged); while ( have_posts() ) : the_post()
?>

<?php thematic_singlepost() ?>

<?php endwhile; ?>
<?php thematic_navigation_below();?>
<?php $wp_query = $temp; ?>

</div>
</div><!-- .post -->

<?php if ( get_post_custom_values('comments') ) thematic_comments_template() // Add a key+value of "comments" to enable comments on this page ?>

<?php get_sidebar('page-bottom') ?>

</div><!-- #content -->
</div><!-- #container -->

<?php thematic_sidebar() ?>
<?php get_footer() ?>


The beginning just declares the file as a page template, and the rest is a duplicate of page.php with a little bit inserted into it. This is the part you actually care about, as it is what makes it possible to loop through whatever category/categories you want. Lines 22-34 (below) are basically making a temporary query based on variables you pass via custom fields:

<?php
$temp = $wp_query;
$categoryid = ($_GET['cat']) ? $_GET['cat'] : get_post_meta($post->ID, 'categoryid', true);
$showposts = (get_post_meta($post->ID, 'showposts', true)) ? get_post_meta($post->ID, 'showposts', true) : 10;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query = new WP_query('cat='.$categoryid.'&showposts='.$showposts.'&paged='.$paged); while ( have_posts() ) : the_post()
?>

<?php thematic_singlepost() ?>

<?php endwhile; ?>
<?php thematic_navigation_below();?>
<?php $wp_query = $temp; ?>

This is just a simple wp_query, driven by variables that uses the stock thematic functions to draw in the post content and the prev/next navigation beneath it.

The $temp variable stores the existing query so we can call it back later (in case you need it later, for use with page categories, for example). You can see that we restore this at the end of the query process.

The $categoryid variable is set within the page editor as a Custom Field of 'categoryid' with the ID of the category you want to display as it's value.

The $showposts variable is also a custom field of 'showposts' with the number of posts you want to display (e.g. 5).

The $paged variable is necessary for the navigation (prev/next links) to appear and function.

To take more control of how the article is displayed you can either filter the thematic_singlepost function, or replace it with the exact article code you'd like to use. To remove the sidebar you can either style it away for the page it should be hidden, or just remove the thematic_sidebar() reference at the end and save it as a separate page template.

Hope this is all clear!


karenmessing comments:

Hi Brian
I tried using this code but it didnt work. any other ideas?


Brian Richards comments:

Are you sure? I just tested it again with my local dev server and it worked fine. Did you add this page template to your child theme folder (or directly within the thematic theme folder if you're not using a child theme)?

When editing the page, did you remember to change the page template to Display A Category (in the page attributes section of the page editor)?

Did you add 2 custom fields to the page, one for categoryid and another for showposts? Each should contain an integer, one for the category you wish to display and the other for the number of posts to display, respectively.


karenmessing comments:

i added the page template to my child theme folder.

and i changed the template to the Display A Category on the people page:

http://www.greenfrontiersenergy.com/?page_id=11

I did add the custom fields to the page but only a portion of the post is displayed and i would like the full post to be displayed along with the post thumbnails

when i changed the template on the news page
http://www.greenfrontiersenergy.com/?page_id=7
my sidebar is no longer there.


Brian Richards comments:

To get your post to display in the format you want, just replace <?php thematic_singlepost(); ?> with what you want to appear in the loop. An example you've described might simply include:
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>

2010-03-24

Buzu B answers:

Here is how I modified the page.php file on thematic to accomplish what you need.


<?php

date_default_timezone_set('America/Los_Angeles');

// calling the header.php

get_header();



// action hook for placing content above #container

thematic_abovecontainer();



?>



<div id="container">

<div id="content">



<?php



// calling the widget area 'page-top'

get_sidebar('page-top');



the_post();



?>



<div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class() ?>">



<?php



// creating the post header

thematic_postheader();



?>



<div class="entry-content">



<?php



the_content();



wp_link_pages("\t\t\t\t\t<div class='page-link'>".__('Pages: ', 'thematic'), "</div>\n", 'number');



edit_post_link(__('Edit', 'thematic'),'<span class="edit-link">','</span>') ?>



</div>

</div><!-- .post -->
<?php
//BUZU: start editing to answer http://wpquestions.com/question/show/id/260
if(is_page('PEOPLE')){
$peoplePage = true;
echo "PEOPLE PAGE";
query_posts('category_name=people');

while(have_posts()){
the_post();
?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php
}
}
//BUZU: STOP EDITING
?>



<?php



if ( get_post_custom_values('comments') )

thematic_comments_template(); // Add a key/value of "comments" to enable comments on pages!



// calling the widget area 'page-bottom'

get_sidebar('page-bottom');



?>



</div><!-- #content -->

</div><!-- #container -->



<?php



// action hook for placing content below #container

thematic_belowcontainer();



// calling the standard sidebar
//BUZU edited the following line.

if(!isset($peoplePage)){ thematic_sidebar(); }



// calling footer.php

get_footer();



?>


NOTE that I have commented the starting and finishing blocks where I edited something. This works on the people page. In my case, my people page is named "PEOPLE" all in capitals. You just need to change that value for the name of your page. For example, to do the same on the news page you would just add another similar block but instead of

if(is_page('PEOPLE')){
you would do

if(is_page('News')){

and then also change the part where it says

query_posts('category_name=people');

for something like

query_posts('category_name=news');

Please note that this modifies the loop, so you night want to add it when all your page has been processed.

I hope this is what you are looking for.

NOTE: I'm editing page.php on thematic template directly. themes/thematic/page.php


Buzu B comments:

you can also add

wp_reset_query();

just before

//BUZU: STOP EDITING

so it looks like

wp_reset_query();
//BUZU: STOP EDITING

to not worry about the loop being modified. I'd really suggest that you do that even if you don't exactly know why.


karenmessing comments:

i will try this. thanks. right now i cant do anything bc my ftp client is saying that the Server closed connection.
: (


Buzu B comments:

Ok, let me know your results. I tested and it works fine.

2010-03-24

AdamGold answers:

Or you can make the 'page.php' template a little different. If what Brian wrote doesn't work, I'll write you a tutorial how to do so.


karenmessing comments:

hi. i just tried brian's solution and it did not work. i have reattached the jpegs of how i would like the pages to appear.