WordPress.org

Ready to get started?Download WordPress

Forums

Using WP_Query within plugin to filter categories (1 post)

  1. khratos
    Member
    Posted 2 years ago #

    Hello,

    I've been trying to write a plugin that filter categories on the homepage.

    Given a set of categories saved as options in the DB., I retrieve them like:
    $categories = get_option('tecf_cat-list');

    Then I use:
    $query = new WP_Query(array( 'category__not_in' => $categories ) );

    but I get a blank page after using this.
    I'm calling the function on the 'posts_request' hook.

    Shouldn't I use WP_Query() from within a plugin? (I tried to modify values of the global $wp_query variable without success).

    Any clues about this incident? (You can point me to the right documentation, I'm not afraid to read).

    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Topic