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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:41:21+00:00 2026-05-17T16:41:21+00:00

I have an array called $array_all; This array will always have 3 possible values:

  • 0

I have an array called $array_all;

This array will always have 3 possible values:

  • 1,
  • 1,2,
  • 1,2,3,

I created a string from the array while in a foreach loop and concatenated a comma at the end.

So, now I have a nice string that outputs the exact value the way it should.

1,2,3, I can copy this output from my browser and insert it into my wordpress function and everything displays perfectly.

The problem arises when I insert this string variable in the wordpress function directly, it fails.

Anybody have any ideas?

Code below:

<?php 
$faux_array = array();
$faux_array_all;

if($five_loans != ''): 
    $faux_array[] = "781";
endif; 
if($logbook_loans != ''): 
    $faux_array[] = "797";
endif;
if($easy_money != ''): 
    $faux_array[] = "803";
endif;

foreach($faux_array as $faux_array_value): 
    $faux_array_all .= $faux_array_value . ',';
endforeach;

echo $faux_array_all;

$args = array
(
    'posts_per_page' => 10,
    'post_type' => 'lender',
    'order' => 'ASC',
    'orderby' => 'date',
    'post__in' => array($faux_array_all)
);
?>
  • 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-17T16:41:22+00:00Added an answer on May 17, 2026 at 4:41 pm

    Mmh for one, you can avoid the loop with just:

    $faux_array_all = implode(',', $faux_array);
    

    which would also solve the trailing comma proble.m.

    On the other hand, you pass an array to post__in that only contains one element (the string). I think what you really want is

    'post__in' => $faux_array
    

    as $faux_array is already an array with IDs.
    Read about Post & Page Parameters, there you can see that you need to pass an array of post IDs to the function, not an array with one string value:

    • ‘post__in’ => array(5,12,2,14,7) – inclusion, lets you specify the post IDs to retrieve
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.