Horje
thematic page display posts - Wordpress Solution
[Solved] - thematic page display posts - Wordpress Solution
Try following codes
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

Solution - 1

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!


Solution - 2

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


Solution - 3

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.

Date: 2022-10-21 05:23:04
Category: Wordpress
More for You