How to change the Joomla article title tag from H2 to H1

The default Joomla 2.5 content article template uses the H2 tag for the title and it is not conducive to proper HTML page formatting.

There is a H1 condition available for 'page_heading' but that displays only when a Menu Item is assigned to the article and the Page Heading parameter is set to display on the page. That's all good, but not all articles will be assigned a menu item.

You may have a menu item assigned to a category and the contained articles each have a different title. In this case, the page heading H1 displays properly on the landing page of the category but each article of the category displays with H2 and no H1 tag is detected.

So here is the fix. If your template override folder does not already have an article default.php, copy components/com_content/views/tmpl/default.php

to

templates/your-default-template/html/com_content/article/

Now open the default.php file and change all this

<?php if ($this->params->get('show_page_heading')) : ?>
	<h1>
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) AND $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
{
 echo $this->item->pagination;
}
 ?>

<?php if ($params->get('show_title')) : ?>
	<h2>
	<?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
		<a href="/<?php echo $this->item->readmore_link; ?>">
		<?php echo $this->escape($this->item->title); ?></a>
	<?php else : ?>
		<?php echo $this->escape($this->item->title); ?>
	<?php endif; ?>
	</h2>
<?php endif; ?>

To this

<?php if ($this->params->get('show_page_heading', 1)) : ?>
		<h1>
		<?php echo $this->escape($this->params->get('page_heading')); ?>
		</h1>
	<?php else:
		if($params->get('show_title')) : ?>
			<h1>
			<?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
				<a href="/<?php echo $this->item->readmore_link; ?>">
				<?php echo $this->escape($this->item->title); ?></a>
			<?php else :
				 echo $this->escape($this->item->title);
			 endif; ?>
			</h1>
		<?php endif;
	endif; ?>

	<?php
	if (!empty($this->item->pagination) AND $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
	{
	 echo $this->item->pagination;
	}
	 ?>

Note that the very last bit of coding is for the top of page pagination and has no effect on the title changes.

So the new condition is saying that if it is a single page with an assigned menu item and the page heading parameter has been set to display, then use the first state else just go ahead with the default state, which is now H1. Only 1 H1 tag will be used when enabled.

Big ups mista Larry!

 

Copyright © 2019 CMSEnergizer.com. All Rights Reserved.
This website is powered by the Joomla!©™ 3 Website Framework | File download and article manager component by CMSE Custom Fields | Advanced Module Manager and Modules Anywhere by NoNumber Elements | Website hosting and development by WebsiteDons

CMSEnergizer.com is owned and operated by Emuzement Net Inc, Tampa, Florida USA