You want get_row
. Per the Codex:
Get all the information about Link 10.
$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10");
The properties of the $mylink object are the column names of the
result from the SQL query (in this example all the columns from the
$wpdb->links table, but you could also query for specific columns
only).echo $mylink->link_id; // prints "10"
https://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Row
Related Posts:
- wpdb->insert: do I need to prepare against SQL injection?
- How do I check for a duplicate record before inserting using wpdb
- How to use $wpdb to delete in a custom table
- WPDB prepare – like % – placeholders?
- $wpdb->update multiple rows, like IN in normal SQL
- Avoiding “Usage of a direct database call is discouraged”
- dbDelta does not create Table, but returns success
- Saving custom form data into database
- passing variables as parameters to stored procedures via wpdb from php-script
- wp-content/db.php : where is this file?
- Quotes in table name
- $wpdb->get_results() returns good result only in first foreach iteration
- WPDB->insert with special characters
- How Can I Use $wpdb in PayPal IPN file?
- $wpdb->query() multiple query support
- Set media metadata (i.e. “dimensions” field) on SVG file after extracting it with a filter
- how to execute different sql query in non-sanitized $wpdb->get_results function
- $wpdb not returning data
- $wpdb Query Result not coming but in phpmyadmin it works [closed]
- WPDB update row with != in where clause
- How to email user after inserting the username in database in WordPress
- Join inside a wpdb query.. confused!
- How to fetch an array in $wpdb?
- Why doesn’t my insert query work?
- How to prevent $wpdb->prepare stripping a leading zero in variable value?
- Generate a unique hash/number for tracking on $wpdb insert
- Fixing wpdb->get_results and wpdb->prepare?
- How does the WXR file differ from the WPDB?
- wpdb->insert and stripslashes against sql injection
- Rolling Back from current WordPress version to previous one
- $wpdb select query by month, post type, and taxonomy term
- WPDB – How to search a column in a table
- using $wpdb to insert a form into a post
- wp_create_user not properly entering password
- How to display user_nicename and usermeta values by custom query in WordPress?
- Foreach loop not working as expected – custom tables and references while submitting a form
- Query insert query executing multiple times
- Undefined offset: 0
- Connect to separate database using $wpdb and authenticate user
- How to access PostgreSQL using WPDB?
- How can I combine one field using wpdb and group by?
- how to use $wpdb->prepare to update a custom table
- $wpdb not being defined in function: Fatal error: Call to a member function query() on a non-object
- Counting posts with argument without retrieving the posts
- How to obtain a reference to $table_prefix in $wpdb object
- Trying to Connect to different database
- how to assign content to a different author while loading content
- Why does this WPDB code throw an empty WPDB error? [closed]
- wordpress $wpdb works only once
- get_results not returning anything
- WordPress core code contains things marked as deprecated by… WordPress?
- Create new database through static page code
- Register custom table for WP to use in a plugin
- wpdb->get_row is selecting the variable as a column name
- WordPress “wpdb->update” – Append Text Value
- Display category names on edit user profile using $wpdb
- Need help converting get_user_meta [keys] into own array
- Can’t call WPDB inside RSS template
- wpdb and acf via wp rest api
- WPDB SQL Ignore `post_status` Parameter
- Save sql file after doing insert wpdb
- wpquery properties last_query and last_result : should these be public or private?
- Can I use wpdb to insert query results into a post?
- Query and get meta as object(stdClass) on wp postmeta table?
- How do I query a table?
- check that the data exists before sending it to wpdb
- wpdb->insert with special chars failing with collation utf8mb4_unicode_520_ci
- no result returns when using $wpdb->get_results with where clause
- SQL queries to another wordpress site
- PHP | left join avg query give me Array()
- update not working using wpdb
- get_posts() SQL Injection
- og:image functions.php
- update_post_meta not working in template_redirect action
- $wpdb select returns empty array
- Show error messages to a user when database insert fails
- Debugging db calls: $wpdb->insert works on test site, not on identical production site
- Intermittent problem writing update_user_meta
- How to use WHERE NOT EXISTS query to avoid duplicate entry using $wpdb to save in custom table?
- Combine posts and postmeta
- Get 3 row ID’s via ARRAY_A
- Getting record from three wpdb tables
- wpdb get_row database query inquiry
- Depreciated Call -> Function wpdb::escape()
- How do I update post based on meta_key in another table?
- Inserting and updating rows with wpdb indreases integer fields by 1 point sometimes
- Retrieve a list of users based on some conditions
- wp_commentdata: error in documentation?
- Echo only gives me the first part of string
- wp-postratings: list current user’s unrated posts
- wpdb select from using array as search parameters
- esc_sql inserting weird chars to DB
- Error inserting row into table
- Retriving array size from serialized data
- How to update user profile or inputing any data to the wp db from external site?
- Get comments after specific date
- selecting row using wpdb which contain special symbols
- get only 1 wpdb and get taxonomy, post to next page [closed]
- $wpdb The query does not contain the correct number of placeholders
- $wpdb:insert, more arguements in $format array than in $data