/**
     * Themes order field callback.
     *
     * @since  1.0.0
     * @access public
     * @return void
     */
    public function field_themes_order()
    {
        $order = array('ASC' => __('Ascending', 'theme-designer'), 'DESC' => __('Descending', 'theme-designer'));
        ?>

		<label>
			<select name="thds_settings[themes_order]">

			<?php 
        foreach ($order as $option => $label) {
            ?>
				<option value="<?php 
            echo esc_attr($option);
            ?>
" <?php 
            selected($option, thds_get_themes_order());
            ?>
><?php 
            echo esc_html($label);
            ?>
</option>
			<?php 
        }
        ?>

			</select>
		<label>
	<?php 
    }
Example #2
0
/**
 * 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());
    }
}