Custom fields for post title on single.php
-
I want to use a custom field in order to put HTML tags into post titles and have found suggestions that say I should use the code below on the single.php in place of
<h1><php the_title(); ?></h1>
:<?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 } ?>
The issues is that my current single.php doesn’t have `<h1><php the_title(); ?></h1>’ to replace. The entire page’s CSS is:
<?php get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/content', get_post_format() ); the_post_navigation(); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; // End of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php if ( 'post' == get_post_type() ) { get_sidebar(); } get_footer();
Any suggestions on where or how to insert the custom fields tag in a situation like this? I’m running a child theme based on Graph Paper Press’s Optics theme.
- The topic ‘Custom fields for post title on single.php’ is closed to new replies.