Why don’t you just do..
add_action( 'wp_head', 'quick_qs_db_css', 100 );
function quick_qs_db_css() { ?>
global $wpdb;
$table_name = $wpdb->prefix . 'qs_css';
$db_css = $wpdb->get_results(
"
SELECT qs_the_css
FROM $table_name
WHERE qs_css_id = 1
"
);
<style type="text/css" id="db-css">
<?php echo $db_css[0]->qs_the_css; //outputs null ?>
</style>
<?php }
Seeing as you are using it everytime head is loaded, it would make more sense than to keep the two separate unless there’s good reason for it?
Related Posts:
- Make a SQL query with wpdb in WordPress
- Pagination with custom SQL query
- How to make an activities stream mixing posts and comments?
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Select from wp_post and multiple meta_value from wp_postmeta
- How to correctly pass values to wpdb->prepare()?
- $wpdb select date range of posts
- How to delete taxonomy term when a wordpress user is removed?
- How to pass orderby params to $wpdb->prepare()?
- List of ways to access WordPress database?
- Passing a SQL query to the WP Query
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Include post_status check within $wpdb query
- wpdb LIKE request shows all database data
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- How to query custom post types with mixed AND & OR statements for custom fields
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- wordpress ajax relationship query
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- how to access query string in wordpress?
- Custom query: Get all posts that are from a certain category?
- How to access custom WordPress database tables
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- Is it safe to access the underlying mysqli object from \wpdb for custom queries?
- Merge two search functions for custom post type
- Debugging wp_query orderby for taxonomy
- Is it possible to query from external database? [duplicate]
- Include post content of linked posts in search
- Getting additional columns from sql
- WordPress query posts with multiple post_meta data
- how to use pre_gets_posts to exclude one queried ID from homepage loop
- Error with function in functions.php?
- Specify strict ‘order by’ in WordPress query
- Getting rid of unwanted nonSQL syntax characters when debugging a query
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Does WordPress have something like Drupal’s DB API?
- get_post() is not returning correct value
- Exclude authors IDs from WP_Query
- Query where ANDing slug values not working
- Loading two different AJAX requests on two different pages
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to load a script code only in posts?
- Slow Query On Search
- Multiple meta_key ordering with pre_get_posts
- WP_Query: apply an SQL function to meta fileld value
- How do I fit WP_Query arguments into a function?
- Create a notification for post field
- Add URL Rewrite Rule To WordPress
- Trying to get property of non-object in: $wp_query
- WordPress dynamic AJAX query
- relation OR instead of AND – Filtered term ID’s in loop
- How to avoid filling up an array each time I run a WP_query?
- How to SQL query posts IDs by categories AND authors?
- Seach and categories not working when ignoring sticky posts in main loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Calling a function with WP_Query only ever brings the first result
- complex query question
- Select Unique Posts for a List of Tags
- Fetching $_POST from Page Template into functions.php
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- wpdb get_results() returns only 2 rows
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- Declare inline background image in functions.php
- I wan to process the following js to process the AJAX Request on my function to calculate author Total Post views
- Optimising amount of calls to custom fields
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- pre_get_posts or $where, which one to use?
- WP Query to order posts by multiple meta fields
- ordering and optimizing functions
- Fire query on ajax post url page
- Slow getting posts from category
- Search Query that Includes Custom Table
- Why WP_Query in functions.php is not working when get_posts works?
- Custom WP_Query with SQL directives for getting posts by authors and terms
- How to return value from sql and display it
- orderby in WP_query doesn’t works
- WP_Query with several meta_query-statements and order by meta_value
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- WP_Query search by multiple meta key and distance
- Query is not work
- Different sql queries count indicator on the main page [closed]
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- Adding css tweak based on page template
- how to use transient method?
- WP_Query and DES sort for Custom Taxonomy based upon a meta field?
- How to write a query-function as a query-shortcode?
- 1500+ duplicate queries via get_option function (query monitor)
- Add custom argument to WP_Query and modify SQL where clause
- get_post_meta bringing back results, but $wpdb->postmeta doesn’t
- Variations as Single Products [closed]
- Group By query based on Custom Field
- Is there another way to retrieve a post_id from post_meta other than a SQL query?
- Excluding a category from frontpage but not from WP_Query
- How to make OR condition in WP_Query
- How to use wp-query to search for posts where post_content OR post_title OR post_name
- How to short circuit a wordpress query that is not related to posts?
- WordPress DB query
- WP_Query equivalent of SQL UNION ALL