• Hi!

    As much as I love this plugin, there are two areas it doesn’t cover: exclusion from archive and search pages. While the latest release has an option for exclusion it only addresses the index page & rss. Is there any decent way to extend (with proper coding) the exclusion feature to include archive/search pages?

    I’ve tried a hack using in_catergory within THE LOOP but to me it’s more a kludge and doesn’t even cover all aspects of proper exclusion (e.g. if there are no other posts than sideblog ones in a month).

    For reference, I’ve included the current (v3.0) hooks used for exclusion, see below.

    Thanks for your support!
    Oliver

    code
    add_filter(‘posts_where’,’sideblog_where’);
    add_filter(‘posts_join’,’sideblog_join’);

    function sideblog_where($query) {
    $sideblog_options = get_option(‘sideblog_options’);

    if(is_home()){
    if($sideblog_options[‘setaside’]){
    $query .= ” AND category_id NOT IN (” . implode(“,”, $sideblog_options[‘setaside’]) . “) “;
    }
    } else if(is_feed()){
    if($sideblog_options[‘excludefromfeeds’]){
    $query .= ” AND category_id NOT IN (” . implode(“,”, $sideblog_options[‘excludefromfeeds’]) . “) “;
    }
    }
    return $query;

    }

    function sideblog_join($query) {
    global $wpdb;
    if(is_home()||is_feed()){
    if(!is_category()){
    $query .= ” LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) “;
    }
    }
    return $query;
    }
    /code

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter olivers

    (@olivers)

    Just wanted to add that also the “single” page needs to take exclusion into consideration, ie. not “previous” and “back” to any of the sideblog posts…

    Thanks,
    O.

    Thread Starter olivers

    (@olivers)

    Feels a little weird speaking with myself, anyway, by playing around I got 95% resolved:

    just changed:

    [...]
    } else if(is_feed()){[...]

    to
    [...]
    } else if(is_feed() || is_search() || is_single || is_archive){
    [...]

    Which seems to exclude it from search, archive & single. However, I’m still struggeling with “posts_nav_link” to not point to any sideblog entries…working on it. ANY hints appreciated.

    O.

    Thread Starter olivers

    (@olivers)

    For completeness sake check here to get previous/next fixed:

    https://ronrothman.com/public/leftbraned/archives/2005/11/01/wordpress-fix-category-exclusions-in-next_post_linkprevious_post_link/

    also you might want to add a “&&!is_admin()” to the above “else if(…” otherwise is_single() will also make the posts disappear from the admin pages.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘sideblog(katesgasis) – exclude from archive/search’ is closed to new replies.