Answer the question
In order to leave comments, you need to log in
Variables for records. Is there a plugin for this?
Good afternoon. I have a news site where some of the text stays pretty much the same from post to post. Only the title and date change. Tell me, is it possible to somehow make variables in order to save time and make the design easier for yourself? I believe there is a specific plugin for this, but I can't find anything.
Answer the question
In order to leave comments, you need to log in
You can use the_content filter to add some information before or after the content
add_filter( 'the_content', 'additional_links_to_content' );
function additional_links_to_content( $content ) {
if ( is_single() && get_post_type() === 'service' ) {
$add = '<h4>Дополнительная информация</h4>';
$add .= '<ul>';
$add .= '<li><a href="#">Ссылка 1</li>';
$add .= '<li><a href="#">Ссылка 2</li>';
$add .= '</ul>';
$content .= $add;
}
return $content;
}
add_filter( 'the_content', 'add_event_date_to_content' );
function add_event_date_to_content( $content ) {
if ( is_single() && get_post_type() === 'event' ) {
if ( $event_date = get_post_meta( get_the_ID(), '_event_date', true ) ) {
$content .= '<p>Дата концерта: ' . $event_date . '</p>';
}
}
return $content;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question