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 8531343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:27:45+00:00 2026-06-11T09:27:45+00:00

I have a page where I need to allow the user to enter a

  • 0

I have a page where I need to allow the user to enter a paragraph of text. Then after that text, insert a shortcode that will render a list of posts, then add more free-form text after that. My thought was that they should be able to insert a shortcode which will output the posts. This way they can simply add the shortcode where they wish the posts to appear.

I currently have the logic which retrieve the posts separated in its own file. Currently I include it in a page by simply using the get_template_part() function:

get_template_part('donation', 'posts');

I looked into how to create a shortcode and included the following code into my functions.php file in order to create the shortcode:

add_shortcode('donation-posts', 'fnDonatePosts');   
function fnDonatePosts($attr, $content)
{
    get_template_part('donation', 'posts');    
}

The donation-posts.php is being properly executed and the posts are appearing, however, they are always positioned BEFORE the content and not in the location that the shortcode was placed.

I have tried removing the get_template_part() function and just output some text and that works fine. So I understand that the get_template_part() may not be the right way to do this, however, I have not been able to uncover a way to do what I am attempting to do (I am sure that there is a way… I just haven’t found it).

I have tried:

include(get_template_directory(). '/donation-posts.php');
include_once(get_template_directory(). '/donation-posts.php') : 

But these stopped processing once they hit the PHP code in the included file.

I have also tried:

$file = file_get_contents(get_template_directory(). '/donation-posts.php');  
        return $file;

But this only returns the contents of the file (as the function name indicates) which means it doesn’t execute the PHP script to return the posts.

Anybody out there done this before?

  • 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-11T09:27:46+00:00Added an answer on June 11, 2026 at 9:27 am

    You may try this, it may solve your problem because get_template_part basically reacts like PHP's require, it doesn’t return but echos the content immediately where it’s been called.

    add_shortcode('donation-posts', 'fnDonatePosts');   
    function fnDonatePosts($attr, $content)
    {        
        ob_start();  
        get_template_part('donation', 'posts');  
        $ret = ob_get_contents();  
        ob_end_clean();  
        return $ret;    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically I have an admin flex page that allows the user to enter text
I need a dropdown list on my page that will allow a user to
I have a page where I need to capture input from a user after
I need to be able to allow a user to enter Vietnamese text into
I have created a page that allows a user to enter a start location
I have a page where I need to allow user to add multiple options
I have a page with a table of stuff and I need to allow
I have a page that I need to design in PhP/Html/Java/CSS that has to
I need something simple; I have page where a user clicks an author to
I have a timed page that I need to use to submit a form

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.