• 1.
    // WP THEME CUSTOMIZER: START
  • 2.
     
  • 3.
    //// REMOVE SECTIONS
  • 4.
    	//// TITLE & TAGLINE
  • 5.
     
  • 6.
    add_action( 'customize_register', 'wpse8170_customize_register' );
  • 7.
    function wpse8170_customize_register( WP_Customize_Manager $wp_customize ) {
  • 8.
        $wp_customize->remove_section( 'title_tagline' );
  • 9.
    }
  • 10.
     
  • 11.
    //// SECTION: LOGO
  • 12.
    function wptuts_theme_customizer( $wp_customize ) {
  • 13.
    $wp_customize->add_section( 'themeslug_logo_section' , array(
  • 14.
        'title'       => __( 'Logo', 'themeslug' ),
  • 15.
        'priority'    => 2,
  • 16.
        'description' => 'Upload a logo to replace the default site name and description in the header',
  • 17.
    ) );
  • 18.
    $wp_customize->add_setting( 'themeslug_logo' );
  • 19.
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
  • 20.
        'label'    => __( 'Logo', 'themeslug' ),
  • 21.
        'section'  => 'themeslug_logo_section',
  • 22.
        'settings' => 'themeslug_logo',
  • 23.
    ) ) );
  • 24.
     
  • 25.
    //// SECTION: Sidebar
  • 26.
    $wp_customize->add_setting('sidebar_position', array());
  • 27.
    $wp_customize->add_control('sidebar_position', array(
  • 28.
    	'label'      => __('Sidebar position', 'Ari'),
  • 29.
    	'section'    => 'layout',
  • 30.
    	'settings'   => 'sidebar_position',
  • 31.
    	'type'       => 'radio',
  • 32.
    	'choices'    => array(
  • 33.
    		'left'   => 'left',
  • 34.
    		'right'  => 'right',
  • 35.
    	),
  • 36.
    ));
  • 37.
    $wp_customize->add_section('layout' , array(
  • 38.
        'title' => __('Layout','Ari'),
  • 39.
    ));
  • 40.
     
  • 41.
    // WP THEME CUSTOMIZER: COLORS
  • 42.
    $colors = array();
  • 43.
    $colors[] = array(
  • 44.
    	'slug'=>'primary_color', 
  • 45.
    	'default' => '#88C34B',
  • 46.
    	'label' => __('Primary Color', 'Ari')
  • 47.
    );
  • 48.
    $colors[] = array(
  • 49.
    	'slug'=>'secondary_color', 
  • 50.
    	'default' => '#333333',
  • 51.
    	'label' => __('Content Text Color', 'Ari')
  • 52.
    );
  • 53.
    $colors[] = array(
  • 54.
    	'slug'=>'headings_color', 
  • 55.
    	'default' => '#333333',
  • 56.
    	'label' => __('Headings Color', 'Ari')
  • 57.
    );
  • 58.
    $colors[] = array(
  • 59.
    	'slug'=>'background_color', 
  • 60.
    	'default' => '#FFFFFF',
  • 61.
    	'label' => __('Background Color', 'Ari')
  • 62.
    );
  • 63.
    foreach( $colors as $color ) {
  • 64.
    	// SETTINGS
  • 65.
    	$wp_customize->add_setting(
  • 66.
    		$color['slug'], array(
  • 67.
    			'default' => $color['default'],
  • 68.
    			'type' => 'option', 
  • 69.
    			'capability' => 
  • 70.
    			'edit_theme_options'
  • 71.
    		)
  • 72.
    	);
  • 73.
     
  • 74.
    	// CONTROLS
  • 75.
    	$wp_customize->add_control(
  • 76.
    		new WP_Customize_Color_Control(
  • 77.
    			$wp_customize,
  • 78.
    			$color['slug'], 
  • 79.
    			array('label' => $color['label'], 
  • 80.
    			'section' => 'colors',
  • 81.
    			'settings' => $color['slug'])
  • 82.
    		)
  • 83.
    	);
  • 84.
    }
  • 85.
     
  • 86.
    // WP THEME CUSTOMIZER: LAST LINE
  • 87.
    }
  • 88.
    add_action( 'customize_register', 'wptuts_theme_customizer', 11 );
  • 89.
    // Posts per page
  • 90.
    add_filter('parse_query', 'wpq_parse_query');
  • 91.
    function wpq_parse_query($query)
  • 92.
    {
  • 93.
        if(!$query->is_main_query())
  • 94.
        {
  • 95.
            return $query;
  • 96.
        }
  • 97.
        if($query->is_archive())
  • 98.
        {
  • 99.
            $query->query_vars['posts_per_page'] = get_option('to_count_archives', 1);
  • 100.
        }
  • 101.
        if($query->is_home())
  • 102.
        {
  • 103.
            $query->query_vars['posts_per_page'] = get_option('to_count_home', 1);
  • 104.
        }
  • 105.
        if($query->is_search())
  • 106.
        {
  • 107.
            $query->query_vars['posts_per_page'] = get_option('to_count_search', 1);
  • 108.
        } 
  • 109.
        return $query;    
  • 110.
    }
  • 111.
     
// WP THEME CUSTOMIZER: START //// REMOVE SECTIONS //// TITLE & TAGLINE add_action( 'customize_register', 'wpse8170_customize_register' ); function wpse8170_customize_register( WP_Customize_Manager $wp_customize ) { $wp_customize->remove_section( 'title_tagline' ); } //// SECTION: LOGO function wptuts_theme_customizer( $wp_customize ) { $wp_customize->add_section( 'themeslug_logo_section' , array( 'title' => __( 'Logo', 'themeslug' ), 'priority' => 2, 'description' => 'Upload a logo to replace the default site name and description in the header', ) ); $wp_customize->add_setting( 'themeslug_logo' ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array( 'label' => __( 'Logo', 'themeslug' ), 'section' => 'themeslug_logo_section', 'settings' => 'themeslug_logo', ) ) ); //// SECTION: Sidebar $wp_customize->add_setting('sidebar_position', array()); $wp_customize->add_control('sidebar_position', array( 'label' => __('Sidebar position', 'Ari'), 'section' => 'layout', 'settings' => 'sidebar_position', 'type' => 'radio', 'choices' => array( 'left' => 'left', 'right' => 'right', ), )); $wp_customize->add_section('layout' , array( 'title' => __('Layout','Ari'), )); // WP THEME CUSTOMIZER: COLORS $colors = array(); $colors[] = array( 'slug'=>'primary_color', 'default' => '#88C34B', 'label' => __('Primary Color', 'Ari') ); $colors[] = array( 'slug'=>'secondary_color', 'default' => '#333333', 'label' => __('Content Text Color', 'Ari') ); $colors[] = array( 'slug'=>'headings_color', 'default' => '#333333', 'label' => __('Headings Color', 'Ari') ); $colors[] = array( 'slug'=>'background_color', 'default' => '#FFFFFF', 'label' => __('Background Color', 'Ari') ); foreach( $colors as $color ) { // SETTINGS $wp_customize->add_setting( $color['slug'], array( 'default' => $color['default'], 'type' => 'option', 'capability' => 'edit_theme_options' ) ); // CONTROLS $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $color['slug'], array('label' => $color['label'], 'section' => 'colors', 'settings' => $color['slug']) ) ); } // WP THEME CUSTOMIZER: LAST LINE } add_action( 'customize_register', 'wptuts_theme_customizer', 11 ); // Posts per page add_filter('parse_query', 'wpq_parse_query'); function wpq_parse_query($query) { if(!$query->is_main_query()) { return $query; } if($query->is_archive()) { $query->query_vars['posts_per_page'] = get_option('to_count_archives', 1); } if($query->is_home()) { $query->query_vars['posts_per_page'] = get_option('to_count_home', 1); } if($query->is_search()) { $query->query_vars['posts_per_page'] = get_option('to_count_search', 1); } return $query; }

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter