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
- The correct method to pass query vars in AJAX using ajaxurl
- Alter query on edit.php
- Displaying post per day
- How to find objects by terms
- How to add active class to custom menu using while loop and wp_list_pages
- Print html when custom field has value inside while loop
- Post from one loop in different containers?
- How to get user by display_name with WP_User_Query
- Custom Loop Pagination on WordPress
- delete an array element when its date expires
- User Defined order on get_categories?
- When would you use $_post instead of $post?
- How do I display the function the_content in this loop?
- Must Use Plugin Causing Query Error
- Facebook “like” open graph meta in header.php
- Get all user meta by meta key instead of ID
- How can I add multiple ‘tax_query’ arrays via a loop?
- Using foreach loop breaks
- mysql query from wordpress page using custom table
- Loop with slider (slider not loading)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Blog posts repeat
- Woocommerce : Can’t get product info in loop
- How to pre populate a form field with a link of a current user’s author profile?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Checkbox doesn’t stay checked, conten
- Can we count the WordPress Loop
- Add content after the first post in WP Loop
- Display an image if odd number of posts in grid
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- 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?
- Last class on last headline?
- working with term_relationships table
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- Shortcode to pull posts
- Echoing a CSS class based on category of post in a list
- Calling function in loop causes repeat data
- How to Generate a list of Most Commented post?
- How to pick “full/thumbnail” images in the loop?
- How to Fix an Archive.php That Displays All Posts?
- List all anchor links on a page
- How to add ASCII symbol after each recent post [closed]
- Search.php gets metadata from first post
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- the_post(); prints out style text into my HTML?
- WordPress Conditional / Multiple Taxonomy Query
- How can I modify this code to make the search box include tags and meta
- update_user_meta as multiple value but with same meta key
- Responsive loop with 3 columns inside row then 2 columns
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- WordPress Recent Posts – Loop
- ACF background-color per post in a WordPress loop
- Advertisement in Loop Posts wordpress
- Let user select the number of posts shown per page jquery error
- Date of last blog update for specific authors only?
- PHP for loop not working as intended
- How to query a staging database?
- Adding custom PHP to existing loop in Genesis
- How to Pass Current Taxonomy Terms into new WP_Query?
- For each 3 posts, show a different post type
- Include a custom field in mysql query
- Loop returns more items than exist?
- Modify category archive page loop on functions.php
- WP_Post is not from correct array
- Post formating on Home page
- divide custom field values in div every two values
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Limit ads appearing more than three times
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- Inserting A Feed and Sidebar into an HTML Page
- Pagination on Custom Loop
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Advanced Taxonomy query, with 3 post types
- Custom single.php files for different post formats
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Troubleshooting “loopback requests that take too long”
- Why does a meta_query break this WP_Query?
- Hide empty categories from get_categories
- Query Concatenation
- Loop on a wordpress Page instead of content coming from the WP text editor
- How to create a loop where loop changes every post?
- Help with if/else loop [closed]