you may need to wrap $slug in quotes
$course = $wpdb->get_results( "SELECT * FROM wp_posts where post_name="$slug"" );
Related Posts:
- meta_value timestamp older than now
- How to limit the number of posts that WP_Query gets?
- Should we trust the post globals?
- Random sort within an already sorted query
- How to know if get_posts() failed?
- post__in for get_posts with a dynamic array
- Using $wpdb to query posts with meta value containing current post_id
- WP_Query to work with custom view
- WordPress Number of Posts Not Changing With posts_per_page
- How to add posts to wp_query result?
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Replace Main Query With Custom Query
- Search query – exact post title match
- posts_per_page doesnt work
- How to start with post number x?
- Exclude posts with empty post_content in wp_query
- Only display a certain number of posts, dependent on how many posts there are available in a query
- Improving WP_Query for performance when random posts are ordered
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Get Posts that are in the current month or later
- How to do set post permalinks using 6 digit random unique function?
- Exclude the first ‘n’ number of posts of a tag from home page?
- posts_per_page option limits the number of Gallery items
- wp_posts table: safely remove unused columns to save database storage
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Do not show children of a category
- Query for first 3 posts to change the look and feel
- Why posts array is empty?
- How to give classname to post if post has no content?
- Exclude some posts from displaying in wp_query based on some condition
- Related Posts function not working
- How to retrieve certain number of images from a wordpress post?
- How to convert query sql to shortcode in wordpress?
- How Can I Always Display A Particular Post First Using WP_Query?
- WordPress Query – Display 5 posts (same post type), each from a given tag
- filter posts based on menu_order
- Show 5 posts and than 3 posts offset with pagination
- wp query custom orderby not custom field
- Query post by meta key of another table
- Sort / Filter Queries
- Advanced Post Display/Pagination/Ordering
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Displaying Results From Custom Taxonomy Query
- WP_Query retrieve custom posts but not the post showing
- Wp_query WooCommerce products
- WP_Query post_tilte search in posts table
- The next_posts_link() works only with original $wp_query
- Accessing the post content with WP_Query
- How to make an activities stream mixing posts and comments?
- How to output comments number of a post per day?
- How can I get all posts data from within a paginated search result?
- If specific user role then sticky post
- Display posts with comments closed, with pagination?
- Only display posts after current date
- I want to query posts in monthly basis
- Custom WP_QUERY $args
- Limiting the number of posts in WP_Query leads to unexpected result
- WP_Query Authors OR Categories
- get query() without post content?
- how to change the number of posts returned in a specific loop without making it global?
- Dynamically switch template on click
- Get all custom post types excepted some…
- Get all comments of author’s posts
- post__in not working with pre_get_posts, but post__not_in does work
- Displaying post excerpt using wpdb query
- Query posts and filter at query time by value of custom meta
- Getting blog pagination to work on page set as front page
- search blog posts by author first name and or last name
- Very complex post query
- Delete post revisions only for a single post
- unique post in “$args” of wp_query display more than one post
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- WordPress query portfolio posts
- Get latest author posts inside the loop
- Display 3 posts with different HTML markup using a loop
- How to show multiple posts thumbnail, title and date in widget
- Group first, 2nd, 3rd, etc posts by category terms
- Manipulated offset and pagination, can’t display last post anymore
- Query to fetch custom taxonomy along with post title
- How to fetch courses in all languages in WordPress?
- How to display particular set of wordpress post on a webpage?
- show loop id post , only first id can read
- Is it possible to query a category with specified posts?
- Query posts from newest category
- WordPress loop uses unmodified posts array, why?
- Show posts between two Custom Fields date
- Query to get data of a post, if in category?
- Order posts by custom field
- Ordering posts alphabetically by meta keys and title
- Grab next post title in archive page
- Remove duplicated posts in the loop if post has more than one category
- Continuous listing from a custom field
- How to store post rating system data post independent?
- Why I getting only 1 post?
- First post in loop displays twice
- Display posts with id equal to relationship value
- Sort Posts Alphabetically Based on Specific Category (Divi)