Advertisement
kobial8

Exclude/Include Any Section in Hompage Using Theme Option

Feb 17th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. Step 01: Have a 'sections' & 'settings' array like this:
  2. IN 'sections' array, put this:
  3.       array(
  4.         'id'          => 'homepage_settings',
  5.         'title'       => __( 'Homepage Settings', 'theme-text-domain' )
  6.       )
  7. IN 'settings' array, put this:
  8.         array(
  9.             'id' => 'testimonial',
  10.             'label' => 'Show Testimonial ?',
  11.             'std' => 'yes',
  12.             'type' => 'select',
  13.             'choices' => array(
  14.               array(
  15.                 'label' => 'Yes',
  16.                 'value' => 'yes',
  17.                 ),
  18.               array(
  19.                 'label' => 'No',
  20.                 'value' => 'no',
  21.                 ),
  22.               ),
  23.             'section' => 'homepage_settings',
  24.             ),
  25.  
  26. Step 02: if your testimonial/Any other sections are not in shortcode, then use get_template_part like this in the homepage:
  27. <?php get_template_part('testimonial'); ?>
  28.  
  29. Step 03: Create testimonial.php OR any sections AND put the content of dynamic testimonial there.
  30. Step 04: Use the code like this in template-welcome.php OR where needed:
  31. <?php
  32.     $testimonial = ot_get_option('testimonial');
  33. ?>
  34.  
  35. <?php if($testimonial == 'no'): ?>
  36.     <?php /* My Changes*/ ?>
  37. <?php else : ?>
  38.     <?php get_template_part('testimonial'); ?>
  39. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement