• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Archive
    • Genesis
    • WooCommerce
    • WordPress
  • Premium
  • Blog
  • About
    • Tools I Use
  • Contact
  • Login
Home » file upload

file upload

How to add PDF upload option to WordPress customizer?

2020-01-09 by Gabor Leave a Comment

1) Add this snippet to functions.php

// =========================================================================
// CUSTOMIZER PDF UPLOAD
// =========================================================================
function pdf_customize_register( $wp_customize ) {
 
    // Add Settings
    $wp_customize->add_setting('customizer_setting_pdf', array(
        'transport'         => 'refresh'
    ));
 
    // Add Section
    $wp_customize->add_section('pdf_section', array(
        'title'             => __('PDF', 'name-theme'), 
        'priority'          => 70,
    ));    
 
    // Add Controls
    $wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'customizer_setting_pdf', array(
        'label'             => __('PDF Upload', 'name-theme'),
        'section'           => 'pdf_section',
        'settings'          => 'customizer_setting_pdf',    
    )));
}
add_action('customize_register', 'pdf_customize_register');

2) Displaying in the Front End

<a href="<?php echo esc_url( get_theme_mod( 'customizer_setting_pdf' ) ); ?>">Download PDF</a>

Filed Under: Free Content, WordPress Tagged With: file upload, pdf

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
WP Rocket - WordPress Caching Plugin
UpdraftPlus Premium

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy
  • Flames Design
© 2021 WP Flames - All Right Reserved