Adding subtitle to excerpt

Posted in: Newspaper
Post count: 38

Hello,

I’m wondering if there’s a way to add subtitles to the excerpts of my post, so that the excerpt has a title and a subtitle. I’d like these to display on my homepage. My website is finalfatloss.com

Just wondering if there’s a way to do this.

In another thread, I saw this code that might be useful:

<?php $td_subtitle_module = get_post_meta($this->post->ID, ‘td_post_theme_settings’, true); ?>
<p class=”td-sub-title”><?php if(!empty($td_subtitle_module[‘td_subtitle’])){echo $td_subtitle_module[‘td_subtitle’];} ?></p>

But I’m not quite sure how to integrate it.

Here’s my front-page-php code:

<?php
/* Home page */

get_header();

// display – Your latest posts
// @see https://codex.wordpress.org/Function_Reference/is_home
if (‘posts’ == get_option(‘show_on_front’)) {

?>
<div class=”td-main-content-wrap td-blog-index”>
<div class=”td-container”>
<div class=”td-crumb-container”>
<?php echo td_page_generator_mob::get_home_breadcrumbs(); ?>
</div>
<div class=”td-main-content”>
<?php
locate_template(‘loop.php’, true);
echo td_page_generator_mob::get_pagination();
?>
</div>
</div> <!– /.td-container –>
</div> <!– /.td-main-content-wrap –>
<?php

// display – A static page
} elseif ((‘page’ == get_option(‘show_on_front’)) && is_front_page()) {

//prepare the loop variables
global $paged;

$td_page = get_query_var(‘page’) ? get_query_var(‘page’) : 1; //rewrite the global var
$td_paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; //rewrite the global var

//paged works on single pages, page – works on homepage
$paged = max( $td_page, $td_paged );

$td_list_custom_title =__td(‘LATEST ARTICLES’, TD_THEME_NAME);
?>

<div class=”td-main-content-wrap td-main-page-wrap”>

<?php
// display Big Grid Mob 1 and the content at the top of the page
if ( empty( $paged ) or $paged < 2 ) { //show this only on the first page
if ( have_posts() ) { ?>
<?php while ( have_posts() ) : the_post(); ?>

<div class=”td-container”>
<?php echo do_shortcode(‘[td_block_big_grid_mob_1 sort=”featured”]’); ?>
<?php the_content(); ?>
</div>

<?php endwhile; ?>
<?php }
}
?>

<div class=”td-container td-pb-article-list td-main-content” role=”main”>
<?php if ( empty( $paged ) or $paged < 2 ) { ?>
<h4 class=”block-title”><span><?php echo $td_list_custom_title; ?></span></h4>
<?php }

$posts_per_page = get_query_var(‘posts_per_page’) ? get_query_var(‘posts_per_page’) : 10;

// query used on Latest Articles section
$wp_query_args = array(
‘ignore_sticky_posts’ => 1,
‘post_status’ => ‘publish’,
‘posts_per_page’ => $posts_per_page,
‘paged’ => $paged,
);
query_posts($wp_query_args);

locate_template(‘loop.php’, true);
echo td_page_generator_mob::get_pagination();
wp_reset_query();
?>
</div>
</div>
<?php

}

get_footer();

Thank you.

Best,
Dan

Post count: 20688

Hi,

You would need to edit the module to achieve this, not the page. I see that you are using module 17 on your homepage. You need to open this file in a text editor and insert the code from this topic – https://forum.tagdiv.com/topic/how-to-write-different-post-titles-on-homepage-or-categories/
Like this, after the excerpt field – https://www.screencast.com/t/reDU9jihSs and also use the class on the paragraph as shown, for better results.
This should be the result – https://www.screencast.com/t/2ZUcN3cId

Thanks

Post count: 38

Simion,

Thank you so much for your awesome reply! It worked like a charm.

Best,
Dan

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.