Answer the question
In order to leave comments, you need to log in
How to display a post in the footer?
All the best!
It is necessary to display an entry in the footer with the following content:
Beginning of the free text " [Product name - get by function] " continuation of the free text.
Condition:
This text should only be displayed on product pages.
I would appreciate your help in resolving this issue.
Answer the question
In order to leave comments, you need to log in
In the footer.php file (better, of course, create a separate file and get_template_part() in footer.php)
https://wp-kama.ru/function/get_posts
// параметры по умолчанию
$args = array(
'numberposts' => 5,
'category' => 0,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
);
$posts = get_posts( $args );
foreach($posts as $post){ setup_postdata($post);
echo 'Произвольный текст';
echo get_the_title($post-ID);
}
wp_reset_postdata(); // сброс
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question