Guest User

11

a guest
Dec 2nd, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2. if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] )) {
  3.     $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
  4.     $menu_items = wp_get_nav_menu_items($menu->term_id);
  5. }
  6. foreach ( $menu_items as $menu_item ) {
  7.     $numbers[] = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
  8. }
  9. for ($i=0; $i < count($numbers); $i++) {
  10.     $id = $numbers[$i];
  11.     $post = get_post($id);
  12.     $title = get_the_title($id);
  13.         $wp_customize->add_setting('tla'.$i, array(
  14.                 'default' => '',
  15.                 'sanitize_callback' => 'theme_sanitize'));
  16.         $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'tla'.$id, array(
  17.                 'label'         => 'Site title: '.$title,
  18.                 'section'       => 'backgrounds',
  19.                 'settings'      => 'tla'.$i)));
  20.         ?> <style type="text/css">.fp-section-<?php echo $i;?>:{background-image: url(<?php get_theme_mod('tla'.$i);?>)}</style> <?php
  21.         echo get_theme_mod( 'tla'.$i );
  22.  
  23. }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment