WordPress.org

Ready to get started?Download WordPress

Forums

Tags in single post, in easel 2.07 theme (11 posts)

  1. quiorvi
    Member
    Posted 1 year ago #

    I have ridden a lot of about to cahnge tags H1 by H2 in single post but, I have a easel 2.07 theme installed in my blog wordpress, and i looked for the php file to change tags H2 by H1 in sibgle post, and i found in my single.php this:

    if (have_posts()) {
    
    	while (have_posts()) : the_post();
    		easel_display_post();
    	endwhile;
    
    } else { ?>

    then i went to displaypost.php and found this:

    if (!function_exists('easel_display_post_title')) {
    	function easel_display_post_title() {
    		global $post, $wp_query;
    		if ((easel_themeinfo('disable_page_titles') && is_page()) || (easel_themeinfo('disable_post_titles') && !is_page()) || (is_page('chat') || is_page('forum'))) return;
    		if (is_page()) {
    			$post_title = "<h2 class=\"page-title\">";
    		} else {
    			$post_title = "<h2 class=\"post-title\">";
    		}
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "<a href=\"".get_permalink()."\">";
    		$post_title .= get_the_title();
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "</a>";
    		$post_title .= "</h2>\r\n";
    		echo apply_filters('easel_display_post_title',$post_title);
    	}
    }

    I tried changing some tags, but it wasn't work.
    Can you help me, please?
    I'm sorry becuse my English isn't good enough, I hope wil understand me.
    Thanks.

  2. Frumph
    Member
    Posted 1 year ago #

    if (!function_exists('easel_display_post_title')) {
    	function easel_display_post_title() {
    		global $post, $wp_query;
    		if ((easel_themeinfo('disable_page_titles') && is_page()) || (easel_themeinfo('disable_post_titles') && !is_page()) || (is_page('chat') || is_page('forum'))) return;
    		if (is_page()) {
    			$post_title = "<h2 class=\"page-title\">";
    		} else {
    if (is_single()) {
    			$post_title = "<h1 class=\"post-title\">";
    } else {
                            $post_title = "<h2 class=\"post-title\">";
    }
    		}
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "<a href=\"".get_permalink()."\">";
    		$post_title .= get_the_title();
    		if (is_home() || is_search() || is_archive() && !is_page()) $post_title .= "</a>";
    if (is_single()) {
    		$post_title .= "</h1>\r\n";
    } else {
    		$post_title .= "</h2>\r\n";
    }
    		echo apply_filters('easel_display_post_title',$post_title);
    	}
    }

    That makes it so that if it's a single page it will use H1 otherwise the H2, is that what you wanted?

  3. Frumph
    Member
    Posted 1 year ago #

    If you have a child-theme, you probably should create a child-functions.php into it and put the function into it so it overrides this function but doesn't modify it in the actual theme.

  4. quiorvi
    Member
    Posted 1 year ago #

    Thank you Frumph.
    This exactly, that i wanted it. I don't know enough php, and i made proves, but didn't work.
    Thank you again.

    Now, when is a single page uses H1 for the post title, and when is blog page uses H2.

    Now I have to resolve, why the rest of the other pages have title with H2. I mean pages which aren't nor single neither blog.

  5. Frumph
    Member
    Posted 1 year ago #

    Well notice in the code above there are conditionals like is_page and is_search and otherwise noted, those conditionals are the ones that refer to what page to use or what not to use.

  6. Frumph
    Member
    Posted 1 year ago #

    So read it like a book

    if (is_page()) {

    If it's a page do this, otherwise do this section:

    if (is_single())

    If it's a single page do this, otherwise if it's not a single post do this:

    (the line of code that is used, which is the h2)

  7. quiorvi
    Member
    Posted 1 year ago #

    Thank you again.

    Finally, i did this.
    I disabled the titles of pages in the theme, and i worte them into the page text.

    Now everything work.

  8. Frumph
    Member
    Posted 1 year ago #

    Heh, that's definitely one way to do it ;/

  9. quiorvi
    Member
    Posted 1 year ago #

    I have a new problem with H1 and H2 tags.
    In my them, there is a file called header.php that put the name of the blog like a H1 in home, in single, in pages etc..

    <body <?php body_class(); ?>>
    <div id="page-head"><?php do_action('easel-page-head'); ?></div>
    <div id="page-wrap">
    	<div id="page">
    		<?php easel_get_sidebar('above-header'); ?>
    		<div id="header">
    
    	            <div class="header-info">
    
    <strong>				<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name') ?></a></h1>
    				<div class="description">"<?php bloginfo('description') ?></div></strong>
    			</div>?>

    I don't want, I only want H1 for the home page, not for the rest of the pages.

    Can you help me , please?

  10. Frumph
    Member
    Posted 1 year ago #

    Reference:
    http://codex.wordpress.org/Conditional_Tags

    You can wrap a check for is_home around the h1

    <?php if (is_home() || is_front_page()) { ?>
    	<h1><a href="<?php echo home_url(); ?>"><?php bloginfo('name') ?></a></h1>
    <?php } ?>
  11. quiorvi
    Member
    Posted 1 year ago #

    Thanks again

Topic Closed

This topic has been closed to new replies.

About this Topic