If you just need to have the print_array($var)
provide an array of values, then you need to change the database function from $wpdb->get_results
to $wpdb->get_var
.
You are retrieving just one value from the database, so get_var
is the function which will return that specific value directly.
Edit:
You can create a comma separated list from the above array using implode(',', $val)
which can later be passed to any other variables.
$values = implode(',', $val);
$result="(" . $values . ')';
Related Posts:
- Query multiple custom post types in single loop
- Specific Loop For 2 Within Each
- spliting posts into two columns
- How to get to a specific position in wp_query?
- Increase offset while looping
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- WordPress query undefined offset in loop
- Issue with custom loop in Archive page
- Limit tags shown in post
- Display articles with a different template in the home page | Solved |
- Problems With Query and/or Template Part and/or PHP
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- How to pre populate a form field with a link of a current user’s author profile?
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Display category name only once inside loop
- Can’t find infinite loop cause
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Load wordpress content in other domain
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Checkbox doesn’t stay checked, conten
- register_taxonomy() take much queries
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- post thumbnail, conditions, else wont work
- Widgets in the loop if active
- List posts that don’t have a specific tag?
- Changing the_posts_navigation() html output
- Can we count the WordPress Loop
- Odd / Even posts add class minus first post
- Get post id within comments loop
- Syntax error when I try to insert my loop into an unordered list? [closed]
- WP_Query fails despite having 1 post
- unable to use ‘new WP_Query’ in AJAX call
- Add content after the first post in WP Loop
- wp_query get the 2nd post
- Loop stopped working
- How to get post ID in a Page?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Custom Pagination is Broken
- Display an image if odd number of posts in grid
- How to loop through all the attached images in a post, and get their url one by one
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- How to list commenters and days since last commented
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Store post content in a php variable and output them using for loop
- Echo a shortcode div after every 3 posts
- How to avoid duplicates when creating recent network posts
- Can’t update multiple rows with $wpdb query
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Why in my theme I can’t see all the statics content under the posts?
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Is the 404 page automatically displayed if a loop returns nothing?
- How do I remove a category from a wordpress loop>
- variable value disappears in a second loop
- Last class on last headline?
- working with term_relationships table
- Show recent posts starting at a specific number archive
- get_the_ID() in the footer returns wrong value
- How to get the last category name of a child category?
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Can I make get_users() query global?
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- How to unlink all posts from tracking same amount of views
- How to display SQL query that ran in WC_Order_Query?
- Custom Post type slider with thumbnail navigation
- Why my loop isn’t working? [closed]
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Only show first image in foreach loop
- use loop to return blog details
- Parse error: syntax error, unexpected ‘}’ [closed]
- How to get current post category details inside “loop”?
- Shortcode to pull posts
- How to pass current loop data into nested loop
- Get all posts as an array ID => Name
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- How to get post ID from button and pass title to Modal
- WP Query Leads to 502 Bad Gateway (Timeout Because Query Takes Too Long)
- home.php show blog posts as grid view
- Problem with custom loop and wp_list_pluck [closed]
- WP_Query multiple post results
- Convert Featured products loop into Recent products loop?
- Wpdb get->results to out the the month from the db
- How to add post meta in while loop?
- Echoing a CSS class based on category of post in a list
- Display child page content of a specific parent on home page
- Do not duplicate posts with multiple categories in multiple loops
- Calling function in loop causes repeat data
- Infinite Loop – WP_Query
- Posts are not looping through correctly
- How to wrap every 3 posts in a div (and close the last div too) [closed]