I want to make the code to display the list of the page title in footer.
I made the following code in functions.php
:
add_action('yamada_action', 'list_page_2');
function list_page_2() {
global $title_yama;
$title_yama = '';
$args = array(
'post_type' => 'page',
'post_status' => 'publish',
);
$queries_yama = new WP_Query($args);
if($queries_yama->have_posts()): while ($queries_yama->have_posts()):$queries_yama->the_post();
$title_yama .= '<li class="aaa"><a href="' .get_permalink(). '">'.the_title().'</a></li>';
endwhile; endif;
wp_reset_query();
return $title_yama;
}
and I inputed in footer.php
the following code:
<?php do_action('yamada_action'); ?>
However, the code displays just text as title.
How should I make the code in order to output including HTML code?
$title_yama
. Usethe_title( '', '', false )
where thefalse
means "don't echo". See the reference. – Sally CJ Nov 3 '18 at 17:16