• Resolved littlecuriosity

    (@littlecuriosity)


    Hi I’m trying to add a custom header for each page of my blog but don’t know where to put the code for as shown by wordpress conditional tags. http://codex.ww.wp.xz.cn/Conditional_Tags

    Anyone got any ideas?

    Thanks
    Judi

    <?php
    /**
     * @package WordPress
     * @subpackage Magazeen_Theme
     */
    
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h5 class="widgettitle">',
            'after_title' => '</h5>',
        ));
    
    /* Comments
    /* ----------------------------------------------*/
    
    function magazeen_comment( $comment, $args, $depth ) {
    
      $GLOBALS[ 'comment' ] = $comment;
    ?>
    
      <li id="comment-<?php comment_ID() ?>" <?php comment_class( 'clearfix' ); ?>>
    
        <div class="comment-wrap clearfix">
    
          <div class="comment-author clearfix">
    
            <?php
              $comment_type = get_comment_type();
              if( $comment_type == 'comment' ) :
            ?>
              <div class="gravatar">
                <?php echo get_avatar( $comment, $size='38' ); ?>
              </div>
            <?php
              endif;
            ?>
            <div class="author">
              <strong class="name"><?php echo get_comment_author_link(); ?>
              <?php if( $comment_type == 'comment' ) : ?>
                <span class="reply"><?php comment_reply_link( array_merge( $args, array( 'reply_text' => '(Reply)', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span>
              <?php endif; ?>
              </strong>
              <?php if( $comment_type == 'comment' ) : ?>
                <span class="date">on <?php the_time( 'l j, Y' ) ?></span>
              <?php endif; ?>
            </div>
    
          </div><!-- End comment-author -->
    
          <div class="comment-text">
            <?php if ($comment->comment_approved == '0') : ?>
              <p><em><?php _e('Your comment is awaiting moderation.') ?></em></p>
                 <?php endif; ?>
    
            <?php comment_text(); ?>
          </div><!-- End comment-text -->
    
        </div><!-- End comment-wrap -->  
    
    <?php
    
    }
    
    /* Featured News Widget
    /* ----------------------------------------------*/  
    
    function featured_news() {
    
      $settings = get_option( 'widget_featured_news' );
      $number = $settings[ 'number' ];
      $category = $settings[ 'category' ];
    
    ?>
    
      <li id="featured-news"><h5>Featured News</h5>
        <ul>
    
          <?php
            $recent = new WP_Query( 'showposts=' . $number . '&category_name=' . $category );
            while( $recent->have_posts() ) : $recent->the_post();
              global $post; global $wp_query;
          ?>
    
          <li class="clearfix">
            <?php if( get_post_meta( $post->ID, "image_value", true ) ) : ?>
    
              <div class="sidebar-preview">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                  <img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=109&h=60&zc=1" alt="<?php the_title(); ?>" />
                </a>
              </div>
    
            <?php endif; ?>
            <div class="sidebar-content">
              <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
              <span><a href="<?php the_permalink(); ?>/#comments" title="Read Comments"><?php comments_number('0 Comments', '1 Comment', '% Comments' );?></a></span>
            </div>
          </li>
    
          <?php
            endwhile;
          ?>
    
        </ul>
        <a href="<?php echo get_category_link( get_cat_id( $category ) ); ?>" class="sidebar-read-more">Read More »</a>
      </li>
    
    <?php
    
    }
    
    function featured_news_admin() {
    
      $settings = get_option( 'widget_featured_news' );
    
      if( isset( $_POST[ 'update_featured_news' ] ) ) {
        $settings[ 'number' ] = strip_tags( stripslashes( $_POST[ 'widget_featured_news_number' ] ) );
        $settings[ 'category' ] = strip_tags( stripslashes( $_POST[ 'widget_featured_news_category' ] ) );
    
        update_option( 'widget_featured_news', $settings );
      }
    ?>
      <p>
        <label for="widget_featured_news_number">How many items would you like to display?</label><br />
        <select id="widget_featured_news_number" name="widget_featured_news_number">
          <?php
            $settings = get_option( 'widget_featured_news' );
            $number = $settings[ 'number' ];
    
            $numbers = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" );
            foreach ($numbers as $num ) {
              $option = '<option value="' . $num . '" ' . ( $number == $num? " selected=\"selected\"" : "") . '>';
                $option .= $num;
              $option .= '</option>';
              echo $option;
            }
          ?>
        </select>
      </p>
      <p>
        <label for="widget_featured_news_category">Which Category is Featured?</label><br />
        <select id="widget_featured_news_category" name="widget_featured_news_category">
          <?php
            $settings = get_option( 'widget_featured_news' );
            $category = $settings[ 'category' ];
    
            $categories= get_categories();
            foreach ($categories as $cat) {
              $option = '<option value="'.$cat->cat_name.'" ' . ( $category == $cat->category_nicename ? " selected=\"selected\"" : "") . '>';
                $option .= $cat->cat_name;
              $option .= '</option>';
              echo $option;
            }
          ?>
        </select>
      </p>
      <input type="hidden" id="update_featured_news" name="update_featured_news" value="1" />
    
    <?php
    
    }
    
    /* Recent News Widget
    /* ----------------------------------------------*/  
    
    function recent_news() {
    
      $settings = get_option( 'widget_recent_news' );
      $number = $settings[ 'number' ];
      $home = $settings[ 'home' ];
    
      if( is_front_page() ) {
        if( $home == "Yes" ) {
          $show = true;
        } else {
          $show = false;
        }
      } else {
        $show = true;
      }
    
    ?>
    
      <?php if( $show ) : ?>
    
      <li id="recent-news"><h5>Recent News</h5>
        <ul>
    
          <?php
            $recent = new WP_Query( 'showposts=' . $number );
            while( $recent->have_posts() ) : $recent->the_post();
              global $post; global $wp_query;
          ?>
    
          <li class="clearfix">
            <?php if( get_post_meta( $post->ID, "image_value", true ) ) : ?>
    
              <div class="sidebar-preview">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                  <img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image_value", true ); ?>&w=109&h=60&zc=1" alt="<?php the_title(); ?>" />
                </a>
              </div>
    
            <?php endif; ?>
            <div class="sidebar-content">
              <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
              <span><a href="<?php the_permalink(); ?>/#comments" title="Read Comments"><?php comments_number('0 Comments', '1 Comment', '% Comments' );?></a></span>
            </div>
          </li>
    
          <?php
            endwhile;
          ?>
    
        </ul>
        <a href="<?php bloginfo( 'rss2_url' ); ?>" class="sidebar-read-more-rss">RSS Feed »</a>
      </li>
    
      <?php endif; ?>
    
    <?php
    
    }
    
    function recent_news_admin() {
    
      $settings = get_option( 'widget_recent_news' );
    
      if( isset( $_POST[ 'update_recent_news' ] ) ) {
        $settings[ 'number' ] = strip_tags( stripslashes( $_POST[ 'widget_recent_news_number' ] ) );
        $settings[ 'home' ] = strip_tags( stripslashes( $_POST[ 'widget_recent_news_home' ] ) );
    
        update_option( 'widget_recent_news', $settings );
      }
    ?>
      <p>
        <label for="widget_recent_news_number">How many items would you like to display?</label><br />
        <select id="widget_recent_news_number" name="widget_recent_news_number">
          <?php
            $settings = get_option( 'widget_recent_news' );
            $number = $settings[ 'number' ];
    
            $numbers = array( "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" );
            foreach ($numbers as $num ) {
              $option = '<option value="' . $num . '" ' . ( $number == $num? " selected=\"selected\"" : "") . '>';
                $option .= $num;
              $option .= '</option>';
              echo $option;
            }
          ?>
        </select>
      </p>
      <p>
        <label for="widget_recent_recent_home">Show on Homepage?</label><br />
        <select id="widget_recent_recent_home" name="widget_recent_news_home">
          <?php
            $settings = get_option( 'widget_recent_news' );
            $home = $settings[ 'home' ];
    
            $options = array( "Yes", "No" );
            foreach( $options as $op ) {
              $option = '<option value="' . $op . '" ' . ( $home == $op ? " selected=\"selected\"" : "") . '>';
                $option .= $op;
              $option .= '</option>';
              echo $option;
            }
          ?>
        </select>
      </p>
      <input type="hidden" id="update_recent_news" name="update_recent_news" value="1" />
    
    <?php
    
    }
    
    /* Sponsored Ad Widget
    /* ----------------------------------------------*/  
    
    function sponsored_ad() {
    
      $settings = get_option( 'widget_sponsored_ad' );
      $code = $settings[ 'code' ];
      $title = $settings[ 'title' ];
    
    ?>
    
      <li id="sponsored-ad">
        <p class="sponsored-ad"><?php echo $title; ?></p>
    
        <?php echo $code; ?>
      </li><!-- End sponsored-ad -->
    
    <?php
    
    }
    
    function sponsored_ad_admin() {
    
      $settings = get_option( 'widget_sponsored_ad' );
    
      if( isset( $_POST[ 'widget_sponsored_ad' ] ) ) {
        $settings[ 'code' ] = stripslashes( $_POST[ 'widget_code' ] );
        $settings[ 'title' ] = strip_tags( stripslashes( $_POST[ 'widget_code_title' ] ) );
        update_option( 'widget_sponsored_ad', $settings );
      }
    
      $settings = get_option( 'widget_sponsored_ad' );
      $code = $settings[ 'code' ];
      $title = $settings[ 'title' ];
    ?>
      <p>
        <label for="widget_code_title">Ad Titles</label><br />
        <input type="text" name="widget_code_title" id+"widget_code_title" value="<?php echo $title; ?>" />
      <p>
        <label for="widget_code">Place Ad Code Below:</label><br />
        <textarea name="widget_code" id="widget_code" cols="" rows="6" style="width:290px;"><?php echo $code; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘HELP custom headers conditional tags’ is closed to new replies.