Forums

[resolved] query_posts("cat=-4") throws fatal error (6 posts)

  1. kchayka
    Member
    Posted 1 year ago #

    I am attempting to exclude a single category from showing up anywhere, primarily in the Archive lists and the prev/next navigation on individual posts. I want it to be a hidden category, but not private.

    Just about every post I've read on this subject refers to Template Tags/query_posts, but this just throws a fatal error no matter what template I add it to, or where in the template it goes, e.g. index.php (or sidebar.php or single.php):

    <?php if (have_posts()) : ?>
    <?php query_posts("cat=-4"); ?>

    Switching the order of those 2 lines doesn't change the resulting:
    "Fatal error: [] operator not supported for strings in path/to/wp-includes/query.php on line 1029"

    This is using a very slightly modified (graphic design changes only) default WP template, and a widgetized sidebar. WP 2.6.3 and php 5.2.

    Can anyone help?

  2. moshu
    Member
    Posted 1 year ago #

  3. kchayka
    Member
    Posted 1 year ago #

    Thanks for that, but I've already tried it. It doesn't work in this case. The category in question is the special "event" category used in the Event Calendar 3 plugin. The plugin itself can hide the category from the Categories list, but not from the Archives or post navigation.

    The ACE plugin doesn't even see the event category, so it won't exclude it, even if I change the calendar pref option to treat events like regular posts. That's when I started looking for solutions like query_posts, which I would happily use if I could only get it to work.

    The error it throws sounds like a syntactical problem, unrelated to any of the plugins I may be using. Why?

  4. kchayka
    Member
    Posted 1 year ago #

    We found another solution. The upcoming 3.2 version of Event Calendar 3 does most of what I need - keeping events out of the archive counts, and I can hide the event category in the Categories list with another plugin (Extended Categories Widget). That just leaves getting them out of the prev/next navigation on individual posts.

    If I find a final solution for that I'll post it here so maybe it will help someone else.

  5. moshu
    Member
    Posted 1 year ago #

    It is built-in, just read the documentation!
    Template_Tags/previous_post_link

  6. kchayka
    Member
    Posted 1 year ago #

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic