Filter Reference / iworks upprev check

Description

iworks_upprev_check is a filter applied to a value to decide show up or not upprev box by the function iworks_upprev_check().

Usage

function my_check($value) {
    # ...
    return false;
}
add_filter('iworks_upprev_check', 'my_check', 10, 1);

Return true to hide upprev box.

Parameters

$value
(boolean) (required) The value decide is upPrev box show or not.

Default: None

Examples

Hide upPrev box if category is “News”:

add_filter('iworks_upprev_check', 'hide_for_category');
function hide_for_category($value) {
    if( is_post() && in_category('News') ) {
        return true;
    }
    return $value;
}

Show box only for posts with id 1, 2 or 501.

add_filter('iworks_upprev_check', 'my_iworks_upprev_check');
function my_iworks_upprev_check($value)
{
    global $post;
    if ( empty($post) ) {
        return $value;
    }
    $allowed_ids = array( 1, 2, 501 );
    return !in_array($post->ID, $allowed_ids);
}

Turn off on main page

function iworks_upprev_turn_off_on_main_page( $check ) {
    if ( is_home() || is_front_page() ) {
        return true;
    }
    return $check;
}
add_filter( 'iworks_upprev_check', 'iworks_upprev_turn_off_on_main_page' );

get snippet to turn off upPrev box on main page

Change Log

Leave a Reply

Your email address will not be published. Required fields are marked *