Excerpt as subtitle in post templates under title

Posted in: Newspaper
Post count: 29

Hi,
How can we ad excerpt instead of subtitle? We have all our old posts that use excerpt.

Thanks

Post count: 21065

Hello!

Please check this guide: https://forum.tagdiv.com/excerpts-introduction/

Thank you!

Post count: 29

I think I have not explained well. Look at the attached image: https://ibb.co/GHs4FqD

Post count: 29

Solved!

Post count: 7

Hi,
please tell me how you solved ?

Post count: 29

Hi,

add this code to your functions.php

function get_excerpt_by_id($post_id){
global $post;
$save_post = $post;
$post = get_post($post_id);
$output = get_the_excerpt();
$post = $save_post;
return $output;
}

and change post subtitle code to call excerpt (file is in td-cloud-library>state>single>tdb_state_single.php

$this->post_subtitle = function () {

$dummy_data_array = array(
‘post_subtitle’ => ‘Sample Post Subtitle!’
);

if ( !$this->has_wp_query() ) {
return $dummy_data_array;
}

$post_subtitle_array = array();

$post_subtitle = get_excerpt_by_id($this->get_wp_query()->post->ID);

$post_subtitle_array[‘post_subtitle’] = $post_subtitle;

if ( empty( $post_subtitle ) ) {

if ( tdc_state::is_live_editor_iframe() || tdc_state::is_live_editor_ajax() ) {
return $dummy_data_array;
}

}

return $post_subtitle_array;
};

Hope it helps.

Post count: 7

Very very thanks,
i’ve used a script to convert excerpt as shortcode to obtain this but your method are better

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