WordPress.org

Ready to get started?Download WordPress

Forums

Max Magazine
Home Page h1 tag elsewhere div tag (2 posts)

  1. Wakil Nikzad
    Member
    Posted 7 months ago #

    Hello Dears,

    I want to make a small modification but doesn't know how to do it.

    When it is homepage the site title/logo should be enclosed with h1 tag.
    When its other pages like single.php or page.php the site title/logo should be enclosed with div tag or something like h4.
    Any help will be appreciated!

    This is the current code in my header.php:

    <?php
    /**
     * The Header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="main">
     *
     * @file      header.php
     * @package   max-magazine
     * @author    Sami Ch.
     * @link 	  http://gazpo.com
     */
    ?>
    <!DOCTYPE html>
    <!--[if lt IE 7 ]> <html class="no-js ie6" <?php language_attributes(); ?>> <![endif]-->
    <!--[if IE 7 ]>    <html class="no-js ie7" <?php language_attributes(); ?>> <![endif]-->
    <!--[if IE 8 ]>    <html class="no-js ie8" <?php language_attributes(); ?>> <![endif]-->
    <!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    
    <title><?php wp_title('|', true, 'right'); ?><?php bloginfo('name'); ?></title>
    
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php
    if ( is_singular() && get_option( 'thread_comments' ) )
    		wp_enqueue_script( 'comment-reply' );
    
    wp_head(); ?>
    </head>
    
    <body <?php body_class(); ?>>
    
    <div id="container" class="hfeed">
    
    <div id="header">	
    
    	<?php
    	/**
    	* Check if the logo image is set in theme options.
    	*/
    	?>
    	<div class="header-wrap">
    		<div class="logo">
    			<?php if (max_magazine_get_option( 'logo_url' )) { ?>
    				<h1>
    					<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    						<img src="<?php echo max_magazine_get_option( 'logo_url' ); ?>" alt="<?php bloginfo( 'name' ); ?>" />
    					</a>
    				</h1>
    			<?php } else {?>
    				<h1 class="site-title">
    					<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    						<?php bloginfo('name'); ?>
    					</a>
    				</h1>
    				<h3>
    					<?php bloginfo('description'); ?>
    				</h3>
    			<?php } ?>
    		</div>	<!-- /logo -->
    
    		<?php if (max_magazine_get_option( 'ad468' )) {?>
    			<div class="ad468">
    				<?php echo max_magazine_get_option( 'ad468' ); ?>
    			</div>
    		<?php } ?>
    
    	</div><!-- /wrap -->
    
    	<div id="nav">
    		<?php wp_nav_menu( array( 'theme_location' => 'primary', 'fallback_cb' => 'max_magazine_menu_fallback',) ); ?>
    	</div>
    
    	<div class="clear"></div>
    
    </div> <!-- /header -->
    
    <div id="content-container">
  2. Jesin A
    Member
    Posted 7 months ago #

    I use the is_singular() function to differentiate and display <h1> or <p> in my blog.

    Remove everything inside <div id="logo"></div> and enter the following

    <?php if(!is_singular()) : ?>
    
    <?php if (max_magazine_get_option( 'logo_url' )) { ?>
    	<h1>
    		<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    		<img src="<?php echo max_magazine_get_option( 'logo_url' ); ?>" alt="<?php bloginfo( 'name' ); ?>" />
    		</a>
    	</h1>
    <?php } else {?>
    	<h1 class="site-title">
    		<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    		<?php bloginfo('name'); ?>
    		</a>
    	</h1>
    	<h3>
    		<?php bloginfo('description'); ?>
    	</h3>
    <?php } ?>
    
    <?php else : ?>
    
    <?php if (max_magazine_get_option( 'logo_url' )) { ?>
    	<div>
    		<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    		<img src="<?php echo max_magazine_get_option( 'logo_url' ); ?>" alt="<?php bloginfo( 'name' ); ?>" />
    		</a>
    	</div>
    <?php } else {?>
    	<div class="site-title">
    		<a href="<?php echo home_url(); ?>" title="<?php bloginfo('name'); ?>">
    		<?php bloginfo('name'); ?>
    		</a>
    	</div>
    	<div>
    		<?php bloginfo('description'); ?>
    	</div>
    <?php } ?>
    
    <?php endif; ?>

    To avoid repetition of code you can also check for the condition separately and pass tags to a variable like $tagopen="<h1>" $tagclose="</h1>" and use it with your code.

Reply

You must log in to post.

About this Theme

About this Topic