the_title(), get_the_title() both returning page rather than post values
-
Hi guys
I am creating a custom theme.
I have set WPAdmin > Settings > Reading > Front page to be “Home” (static page)
For “Home”, I have WPAdmin > Pages > “Home” > Template set to “Front Page” which is the template name for the template I’ve created for the homepage (front_page.php).
I have added several test posts under 2 categories : 1) smallprint 2) quote
Now..
On front_page.php, I want to get all posts with category of “quote” and loop through them, outputting the title and content of that post.
The code below seems to output the content of the post fine, but the title it outputs is the page title (“Home”), not the post title.
I’ve also tried echo the_title() and using the WordPress Loop. All to no avail.
<?php global $quote; $firstQuote = true; $quote_cat_id = get_cat_ID('quote'); $quotes = get_posts('category='.$quote_cat_id); foreach($quotes as $quote) : setup_postdata($quote); ?> <div class="item <?php if ($firstQuote) echo "active"; ?>"> <blockquote> <p><span>“</span><?php echo get_the_content(); ?><span>”</span></p> <footer><?php echo get_the_title(); ?></footer> </blockquote> </div> <?php $firstQuote = false; endforeach; ?>
This is really confusing me, could anyone point out where I’ve gone wrong? I feel I’ve tried everything I can and this is a last resort.
Thanks in advance.
- The topic ‘the_title(), get_the_title() both returning page rather than post values’ is closed to new replies.