ThemeShaper Forums » Thematic

[closed]

create a custom Page loop

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

    hi there, when i want to rewrite, let's say the index loop i use the childtheme_override_index_loop function.

    and now when i try to target the loop for a page, I can't get it working. i can't find any function that says something like childtheme_override_page, so i guess it is

    function childtheme_override_single_post () {
    //do nuffi'n
    }

    but it does not seem to work. do i have to make a template for a page or what is this? anyone that knows?!

    Posted 3 years ago #
  2. if you take a look at page.php you will see there is no loop function. so i think you need to make a template.

    Posted 3 years ago #
  3. dynamitharry
    Member

    Thanks!
    Why is it so?
    just curious..
    does not page need: (have_posts()) : the_post(); etc..etc..

    Posted 3 years ago #
  4. don't really know why there isn't a thematic_page loop.. except that it is just as easy to duplicate and modify a page.php in your child theme OR create a new template.

    technically it IS still within the wordpress loop.. which you can see b/c page.php uses the_content() and other functions that only work inside the loop. by virtue of you being on that particular page you already know that it exists. so you don't need have_posts()) : the_post()

    that all made more sense in my head

    Posted 3 years ago #
  5. dynamitharry
    Member

    ahaa, thanks!

    well by the way..
    reason why i wanted to modify the page.php is that i want to display a little list of the most recent post from my news category below the content of the page. the only problem with this seems to be that when i do this it get a bit confused and shows images from the news.

    function add_a_little_loopie () {
    if (is_page(66)) {
    ?>
    <?php $recent = new WP_Query("cat=1&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
    
    <?php the_title(); ?><br />
    
    <?php endwhile; ?>
    
    <?php } }
    add_action('thematic_belowpost','add_a_little_loopie');

    do you have any idea why? do i need to close the loop in some way or do i have to put it outside or so..?

    Posted 3 years ago #
  6. dynamitharry
    Member

    got it! just needed to add: wp_reset_query(); after the endwhile;

    Posted 3 years ago #
  7. yup... or i also like to use get_posts() for this type of thing b/c it doesn't monkey w/ the query object

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.