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

  • SEARCH
  • Home
  • 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 9181539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:20:23+00:00 2026-06-17T18:20:23+00:00

I use a WordPress blog and I want to show a post without adding

  • 0

I use a WordPress blog and I want to show a post without adding anything to database.
What I want to say is:

I generate a post when page loads,and prepend it in homepage.
I’ve searched and found wp_insert_post() function but it also add to database.
How can i do this with php?

For example:
There is a post array which is generated by a query.How can I insert my post to this array before page loaded?

I want clear my idea.Here’s step by step what i want.

*1)*Im generating an array like that
$arr[‘title] = “my title”,
$arr[‘content’] = “my content”,

*2)*WP sends a query to database and have the posts am i right? And there is an array,to show on the theme and main page?
At this point i want to add my external array(generated in step1 ) to this array(generated by WP via a query)

3) By this way i will be able to add a post without adding it to my database.

  • 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-06-17T18:20:24+00:00Added an answer on June 17, 2026 at 6:20 pm

    You can simply add your virtual post in one of your theme templates as raw HTML.

    Alternatively, if you’re feeling adventurous, you could modify the main query results and include your post inside:

    add_action('loop_start', function($query){
    
      // create the post and fill up the fields
      $post = new WP_Post((object)array(
        'ID'           => -1,
        'post_title'   => 'Bla blah',
        'post_content' => 'Your content',
      ));
    
      // add it to the internal cache, so WP doesn't fire a database query for it
      // -1 is the ID of your post
      if(!wp_cache_get(-1, 'posts'))
        wp_cache_set(-1, $post, 'posts');
    
      // prepend it to the query
      array_unshift($query->posts, $post);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a custom page for my WordPress blog that will execute
I want my WordPress blog to have a page called music. On that page
I want to use this code on my WordPress blog, but it's not working:
I have an idea for my wordpress blog. I want to have a page
On my home page of my WordPress blog I want to extract headings wrapped
I want to place a photo gallery on my wordpress blog. I use NextGEN
My research group uses a Wordpress blog. Frequently I want post snippets or even
How do you use wordpress capabilities (using wp-blog-header.php) and keep the permalinks behave? I
I have a WordPress blog. I use a wide variety of fonts. Now I
I want to paginate comments section of my wordpress blog using ajax. How would

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.