コード例 #1
0
function hocwp_option_reading_defaults()
{
    $alls = hocwp_option_defaults();
    $defaults = hocwp_get_value_by_key($alls, 'reading');
    if (!hocwp_array_has_value($defaults)) {
        $defaults = array('statistics' => 0, 'trending' => 0, 'search_tracking' => 0, 'enlarge_thumbnail' => 0, 'excerpt_length' => 75, 'post_statistics' => 0, 'sticky_widget' => 0, 'redirect_404' => 0, 'breadcrumb_label' => '', 'disable_post_title_breadcrumb' => 0, 'link_last_item_breadcrumb' => 0, 'go_to_top' => 0, 'go_to_top_on_left' => 0, 'scroll_top_icon' => '', 'content_none_title' => '', 'thumbnail_image_sizes' => array(), 'products_per_page' => hocwp_get_product_posts_per_page());
    }
    return apply_filters('hocwp_option_reading_defaults', $defaults);
}
コード例 #2
0
function hocwp_setup_theme_pre_get_posts(WP_Query $query)
{
    if ($query->is_main_query()) {
        if (is_home()) {
            $options = hocwp_option_home_setting();
            $posts_per_page = absint(hocwp_get_value_by_key($options, 'posts_per_page'));
            $query->set('posts_per_page', $posts_per_page);
        } elseif (is_search()) {
        }
        if (hocwp_wc_installed()) {
            if (is_search() || is_archive() && function_exists('is_woocommerce') && is_woocommerce()) {
                if (!isset($_POST['ppp'])) {
                    $query->set('posts_per_page', hocwp_get_product_posts_per_page());
                }
            }
            if (is_search()) {
                $search_cat = hocwp_get_method_value('search_cat', 'request');
                if (hocwp_id_number_valid($search_cat)) {
                    $tax_query = array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => array($search_cat)));
                    $query->set('tax_query', $tax_query);
                }
            }
        }
    }
    return $query;
}