ThemeShaper Forums » Thematic

[closed]

custom index loop and widget logic

(4 posts)
  • Started 8 years ago by ashbydesign
  • Latest reply from ashbydesign
  • This topic is not resolved
  1. ashbydesign
    Member

    I'm getting my knickers in a twist here and wonder if there's anyone a bit more savvy about conditional coding and query_posts who could help me out. I've done the most learning on this forum than any other… I'm hoping someone can lend me their brains.

    The website in question:
    http://subdomain.penandtonic.org/

    I'm customizing my index loop to only feature 2 posts from the news category using the following function:

    //********** MODIFY HOME PAGE LOOP **********
    function PTfilterposts() {
    global $wp_query;

    if (is_home()) {
    $defaults = $wp_query->query_vars;
    $filter = array('category__in'=> 1, posts_per_page => 2);
    $args = wp_parse_args( $filter, $defaults );
    query_posts($args);
    }
    }
    add_action('thematic_above_indexloop','PTfilterposts');

    Works fine. But then I'm using widget logic to allow me to place different widget content on the sidebars - and I'm running into difficulty with the news archive and home.

    is_home() || !is_category(array('news','projects'))

    This displays the widgets I want on the home page, different ones on the projects archive page:

    http://subdomain.penandtonic.org/category/projects/

    - but I can't stop it displaying the home page widgets on the news archive page. I want different ones, like the projects archive… but no such luck

    subdomain.penandtonic.org/category/news/

    I'm guessing wordpress is counting the home page as a news archive page once it has been defined by the query. How do I tell it otherwise????

    N.B. I've had problems with widget logic and the home page: only by adding the not! command can I manipulate the widget to display widgets on the home page (i.e. is_home() does not work on its own - I have looked and looked and there seems to be no resolution to this)

    Posted 8 years ago #
  2. you could try widget context instead:
    http://wordpress.org/extend/plugins/widget-context/

    or failing that, you could create a special sidebar that only displays on the home page and use that

    Posted 8 years ago #
  3. ashbydesign
    Member

    Thanks for this suggestion. I tried widget context, and it has resolved the home page issue. However, I still need widget logic to carry out the more complex conditional requirements: not sure if I should be doing this… 2 conditionals widgets. Eh well: would be useful to understand where I may be going wrong in setting up my query in the first place.

    (BTW - I tried removing the sidebar in functions, with the conditional is_category('news') just to see what would happen - and it disappeared from the home page too. So something is fishy in my set-up…

    Appreciate the help.

    Posted 8 years ago #
  4. ashbydesign
    Member

    May I recommend Dynamic Widgets plugin for doing the job and solving my problem all-in-one (urm, nice and WYSIWYG too) - though if anyone can explain what could be wrong with the simple conditionals… I think it's all a bit long-winded for this forum, so here's the plugin link: Dynamic Widgets Plugin made by qurl

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.