Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:18:16+00:00 2026-05-23T09:18:16+00:00

In my WordPress site, I am trying to retrieve the most recent 10 posts

  • 0

In my WordPress site, I am trying to retrieve the most recent 10 posts and store them in a string. After that I will write this content into a text file. Below is the code I am using.

<?php $str  = ''; ?>
<?php
require_once('../wp-blog-header.php');
query_posts('&showposts=10&order=DESC&caller_get_posts=1');  
while (have_posts()) : the_post(); ?>     
 <?php $str .= '<a href="' . the_permalink() . '">' .the_title() . '</a>'; ?>
<?php endwhile; ?>
<?php $fp = fopen("latestposts.txt", "w");
 fwrite($fp, $str);
fclose($fp);?>

The problem is, when I execute this page, the permalink and title are returning in this page and empty ”….” tags are coming in text file. If I am not using the string, the href tags are returning correctly in the same file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:18:17+00:00Added an answer on May 23, 2026 at 9:18 am

    the_permalink() and the_title() does not return anything they are to print values.

    You have to use their get_ version. Those are get_permalink() and get_the_title()

    <?php $str .= '<a href="' . get_permalink() . '">' .get_the_title() . '</a>'; ?>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a WordPress site that has six lists on a page,
I am trying to set up a page on a wordpress site that displays
I am trying to add some jQuery to a Wordpress site so that when
I'm developing a Wordpress site that will let (registered) users upload an image and
This is for a Wordpress site powered by Thesis. What I'm trying to do
http://codex.wordpress.org/WPMU_Functions/get_current_site#Examples In Wordpress, I am trying to retrieve the site name inside a plugin
I'm trying to write a template for a Wordpress site to use as a
I was browsing a WordPress site, and spotted this line <?php if ( function_exists('dynamic_sidebar')
I'm working on a wordpress site, with a blog post that ends like: http://www.blog.com/?p=2
I'm moving a locally developed wordpress site to a client's server so I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.