Return to Snippet

Revision: 19696
at October 28, 2009 17:17 by gd6d


Initial Code
1. Enter title without HTML

2. Create a custom field for the title with HTML

3. Output custom field on pages you want the HTML


For example, on the single.php page where you would have used

<h1><php the_title(); ?></h1>
Now you use

<?php

   $html_title = get_post_meta($post->ID, "HTML_title", true);

   if ($html_title) { ?>
                
      <h1><?php echo $html_title; ?></h1>
                
   <?php } else { ?>
                
      <h1><?php the_title(); ?></h1>
                    
<?php } ?>

This checks and sees if that custom field is set. If it is, it outputs that. If not, it uses the regular function.

Because the RSS templates use the regular the_title() function, your titles are same from being weirdified in feed readers.

Initial URL
http://digwp.com/2009/10/custom-fields-for-html-post-titles/

Initial Description

                                

Initial Title
Custom Fields for HTML Post Titles

Initial Tags
wordpress

Initial Language
PHP