ThemeShaper Forums » Thematic


query_posts and is_home issues

(5 posts)
  • Started 10 years ago by darrenc
  • Latest reply from middlesister
  • This topic is not resolved
  1. darrenc

    on the homepage of my site i want to simply display 3 posts from a certain category. i devised this code, put into my child functions.php:

    add_action("thematic_indexloop", "font_page_loop");
    function font_page_loop(){

    however i noticed that now when i try to do other things on the page using "is_home()" they don't work anymore... almost like the homepage doesn't believe it is a homepage anymore.

    i know that i can workaround this by testing for is_category('40') instead, but my curiosity is getting the better of me:

    - what is actually happening here?
    - is this the best way to be accomplishing what i want?
    -- if not... then what is a better way?

    thanks for any replies.

    Posted 10 years ago #
  2. I prefer making a homepage template then adding the code you can find here:
    (via Pictrix)

    Posted 10 years ago #
  3. darrenc

    with respect, i don't think that's the most elegant solution. i've done it in 4 lines of code and without creating additional pages to manage. instead of making another homepage template, i could use the childtheme_override_index_loop() in function.php, but i was option for a surgically precise modification since i only need to change 2 things.

    i'm sure there is a way, and i thought query_posts was it... but like i said, i am getting those weird side effects and am curious why.

    Posted 10 years ago #
  4. jmtmay

    Darrenc, Did you ever figure this out? I'm having the same problem.

    I'm using query_posts, then try to use is_home and it doesn't work. As soon as I take out the query_posts the is_home works.

    Posted 10 years ago #
  5. middlesister

    This is expected behaviour. Using query_posts will make a new database query, and changing the query will affect global values including changing the conditionals.

    You might get lucky if you put in a "wp_reset_query()" immediately after the loop.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.