Regarding a custom loop and output HTML tags

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?

Read more here:: Regarding a custom loop and output HTML tags

Leave a Reply

Your email address will not be published. Required fields are marked *