Viewing 14 replies - 1 through 14 (of 14 total)
  • Hi @simonsharayha

    To make that kind of edit, you’ll want to set up a child theme for your modifications. This protects them during future theme updates.

    Once you have your child theme in place, copy the content-home.php file from your the original theme into your child theme folder.

    In that file, you’ll want to find the following section:

    		<?php if ( 'link' == $format ) : ?>
    			<?php the_title( '<h1 class="entry-title"><a href="' . esc_url( pictorico_get_link_url() ) . '" rel="bookmark">', '</a></h1>' ); ?>
    		<?php else : ?>
    			<?php the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); ?>
    		<?php endif; ?>
    

    and change the h1 opening and closing tags to h2, like this:

    		<?php if ( 'link' == $format ) : ?>
    			<?php the_title( '<h1 class="entry-title"><a href="' . esc_url( pictorico_get_link_url() ) . '" rel="bookmark">', '</a></h1>' ); ?>
    		<?php else : ?>
    			<?php the_title( '<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>' ); ?>
    		<?php endif; ?>
    

    You may also want to make similar changes in a copy of other template files that display multiple posts like archive.php ??

    Thread Starter simonsharayha

    (@simonsharayha)

    Thank you Chad for your reply.

    both code sections look the same, do you mean change every h1 to h2 in the code?

    like this?

    <?php if ( 'link' == $format ) : ?>
    			<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( pictorico_get_link_url() ) . '" rel="bookmark">', '</a></h2>' ); ?>
    		<?php else : ?>
    			<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
    		<?php endif; ?>
    Thread Starter simonsharayha

    (@simonsharayha)

    I guess that worked! thank you!
    another issue, now i want to change the widget title in the footer from h1 to h2 or h3 because by default they are H1

    both code sections look the same, do you mean change every h1 to h2 in the code?

    YES! Sorry, about that – and thanks for reading between the lines of my failed copy and paste!

    another issue, now i want to change the widget title in the footer from h1 to h2 or h3

    Try adding this snippet child theme’s functions.php file to change the h1s into h2s:

    <?php
    
    function pictorico_sidebar_tweaks( $sidebar ) {
    	global $wp_registered_sidebars;
    	if ( isset( $sidebar['before_title'] ) ) {
    		$id = $sidebar['id'];
    		$s = $wp_registered_sidebars[ $id ];
    		$s['before_title'] = preg_replace( '/^<h1/', '<h2', $s['before_title'] );
    		$s['after_title'] = '</h2>';
    		$wp_registered_sidebars[ $id ] = $s;
    	}
    }
    add_action( 'register_sidebar', 'pictorico_sidebar_tweaks' );

    you can also change the ‘h2’ to an ‘h3’ if you’d like ??

    herculesnetwork

    (@herculesnetwork)

    Hello @chad ?? How would this snippets change title, posts, and title blogs? Thanks

    Hi @herculesnetwork!

    Changing things like the site title or post titles would be different ??

    For that, I’d recommend setting up a child theme, and making copies of the files that display those titles in your child theme folder.

    Then you can edit the HTML for those elements as needed – the process for some titles may be different than others, depending what exactly you’re changing.

    If you run into trouble, open a new thread and let us know how far you’ve gotten ??

    herculesnetwork

    (@herculesnetwork)

    Hi @chad … and Sorry, I was very inaccurate in my words:
    I was thinking of a snipts like this yours, to set on any theme, A H1 tags for blogname and H2 for post_title ??
    Yes I use child theme ??
    You could write something like this snipt above but to set H1 to blog name and H2 to post title?
    Thanks

    Don’t worry, you were quite clear ??

    The difference is that sidebar title’s HTML tags are generated through a function, while site titles and post title’s are not – the HTML is written into the theme directly.

    To change those ones, you’d edit the theme files (using a child theme to be safe) directly.

    For example:

    On Pictorico, you would copy the parent theme’s header.php file into the child theme.

    Then, on this line:

    <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>

    You could change the h1 and /h1 to whatever you needed.

    You could do something similar with other files like content.php or content-single.php

    A snippet like the one we used for widgets won’t make all of those changes for you, but if you isolate the headings you want and update them in a child theme, you’ll be in good shape ??

    Hi @chad. Thank you very much for your help, I greatly appreciated it!
    ?
    ?? I’m sorry for the delay in thank you, I’ve been very absent these days doing something that was giving me a lot of work and stress ??

    ??? Thanks a lot, this will help me a lot to make my tags better on many themes, yes I use child theme ??

    Thank you so much!

    You’re welcome!

    Hi, I am using theme ‘Just write‘. I wanna change the post title to H1 from H2. But I dont from where I have to change. So can you please help me.

    Here is my website – https://thinksteer.com/

    Hi @ronroy!

    Each theme is a little different, so the file/element structure won’t be the same as the Pictorico theme, which this particular forum is geared towards ??

    I was going to recommend posting in the Just Write theme’s support forum (thanks for the link to the theme page!) but it looks like you already have a thread open there ??

    I’d suggest monitoring that thread, as the forum for the specific theme will be the best place to work from.

    Hi @chad,
    You can see that I don’t get any reply from there So please suggest me how to change the title. Please, it’s really very much urgent for me.

    Hi @ronroy2!

    Unfortunately this isn’t a theme I have experience with so I’m not able to provide the code examples you’d need. The developer or another user of the theme who has worked with the files will be better able to assist.

    You can try to use the above code snippets as a starting point – you’d most likely need to locate where the_title() is being called in your single.php file.

    You’d then want to modify the HTML in a copy of that file using a child theme.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘How to Change post title tag from H1 to H2 ?’ is closed to new replies.