/** * Themes orderby field callback. * * @since 1.0.0 * @access public * @return void */ public function field_themes_orderby() { $orderby = array('author' => __('Author', 'theme-designer'), 'date' => __('Date (Published)', 'theme-designer'), 'modified' => __('Date (Modified)', 'theme-designer'), 'ID' => __('ID', 'theme-designer'), 'rand' => __('Random', 'theme-designer'), 'name' => __('Slug', 'theme-designer'), 'title' => __('Title', 'theme-designer')); ?> <label> <select name="thds_settings[themes_orderby]"> <?php foreach ($orderby as $option => $label) { ?> <option value="<?php echo esc_attr($option); ?> " <?php selected($option, thds_get_themes_orderby()); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <label> <?php }
/** * Filter on `pre_get_posts` to alter the main query on theme pages. * * @since 1.0.0 * @access public * @param object $query * @return void */ function thds_pre_get_posts($query) { if (!is_admin() && $query->is_main_query() && thds_is_archive()) { // Back-compat with TH system. if (get_option('th_sample_child_themes')) { $query->set('post__not_in', get_option('th_sample_child_themes')); } // Set the themes per page. $query->set('posts_per_page', thds_get_themes_per_page()); $query->set('orderby', thds_get_themes_orderby()); $query->set('order', thds_get_themes_order()); } }