Newbie ? About adding code within already existing action hooks.
-
Forgive me if I am calling an action hook a filter hook and vice versa..I am still confused as to tell them apart.
Anyway, I understand and have been successful in creating my own custom filters and actions and such; however, those have been pretty straightforward. Anyway, my question is how do I go about adding in my functions.php file code to an existing action hook that already has code within it.
Specifically:
I am using a child theme based on thematic framework. I needed a way to add ascending order to my posts-in-category page. I was able to accomplish this by adding the following code to the thematic_category_loop() in my content-extensions.php file.
$cat = get_query_var('cat'); $page = get_query_var('paged'); query_posts("cat=$cat&paged=$page&orderby=date&order=ASC");
It works and I could just leave it this way I know; however, I wanted to use this as a learning experience. Is it possible to add this bit of code to the beginning of the thematic_category_loop() via the functions.php file?
The thematic_category_loop() already contains the following code by default:
while (have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" class="<?php thematic_post_class(); ?>"> <?php thematic_postheader(); ?> <div class="entry-content"> <?php thematic_content(); ?> </div> <?php thematic_postfooter(); ?> </div><!-- .post --> <?php endwhile; }
and I add what I have just above all of this code. So would I essentially have to remove this whole action and then recreate my own special function to replace it with, which would include not only my code, but the code that is already there by default?
Hopefully that makes sense. Thanks!
Mike
- The topic ‘Newbie ? About adding code within already existing action hooks.’ is closed to new replies.