Try this
global $wpdb;
$results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE `post_type`='post' AND `post_status` = 'publish' LIMIT 20" );
foreach ($results as $result) {
echo '<div class="card">
<div class="img">
<img src="'.get_the_post_thumbnail_url( $result -> ID, 'thumbnail' ).'" alt="">
</div>
<div class="info">
<h5>'.$result->post_title.'</h5>
</div>
</div>';
}
Related Posts:
- How to get the custom header image’s alt text?
- PHP unit testing WordPress?
- WordPress GET parameters causing 404 Not Found
- Is there a way for a plugin to add an attribute to the tag of a theme?
- is_page() not working from within a plugin
- wp_set_object_terms and arrays
- How to create custom php script page
- Metabox repeating fields – radio buttons not saving correctly
- Create WordPress pages with PHP
- How do i hide the if the appears
- How to return the_excerpt (without echo)?
- How to handle a custom form in wordpress to submit to another page?
- Replacing mysql_real_escape_string in WordPress theme
- WordPress 4 invalid username special charachters issue
- TCPDF get_post_meta outside the loop
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- Easiest way to show total number of subpages
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- How do I test PHP files in WordPress?
- echo CHILD / SUB CATEGORIES of the CURRENT CATEGORY only
- ACF check if variable has http, if else return string
- Correct syntax to html php conversion
- Can’t load WP function into external function
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- Adding a div at the bottom of a sidebar
- WSoD being caused by this piece of code
- How to display data from custom table in wordpress phpmyadmin
- how do I get a specific post from a post with a subcategory in WP
- PHP Fatal error: Out of memory in WordPress [closed]
- Theme developement – incative sidebars
- add_cap not working
- Scrape external webpage for first image and add it to new post
- Help solving t_echo php error while using echo do_shortcode
- How i can get post data from database when i am getting post id from url in wordpress
- Hook called before text widget save
- How to list commenters and days since last commented
- Mixing variables into an array when inserting values
- meta box not display data input in the textarea
- wpdb prepare insert table doesn’t work
- How to modify the default feed via a function
- dynamic page using php from sql database
- Loop over Array and get the distinct ids
- Store metakey value as an array
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Custom Post type slider with thumbnail navigation
- how to add re-order to wp user panel of wordpress?
- How to add new CSS file to new PHP file
- WordPress SQL JOIN query
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- WP_Query and help with the loop for magazine front page
- Why does PHP called with Jquery AJAX not allow additional php code to be added?
- Infinite Loop in WordPress Installation
- send popup after wp_redirect()
- Validate search against a list of codes in wordpress
- Custom Post Status 404 URL
- Checkbox doesn’t save inside metabox
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- A function to get the content of a page
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Trying to create a shortcode to display categories with a specific product tag
- Using the get_template_part method within an mu-plugin not possible?
- Updating user meta adds string count to value?
- How do I integrate vanilla Javascript to a wordpress website?
- I want to retrieve the email or username data entered for password reset, but failed. how can I do it?
- Looping through dummy posts and showing them in the main index.php
- Force Sidebar on Full Width page
- Exclude category from function – PHP
- ACF – Can’t get custom post type by taxonomy
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How to count posts posts if they are in a separate content page?
- Ajax in a class instantiated via shortcode
- append data to mysql table via submit button coded in php – not working
- When working with a post, almost all wp_postmeta are deleted
- PHP – Woocommerce 3.2 Add variable shipping insurance with multiple “else if ” conditions
- Why transition_post_type hook is called twice for the same post?
- Shortcode Works for Logged in Users but Not Working for Guest
- Fix mod_pagespeed Fetch timed out error on bitnami AWS wordpress installation
- Adding my own custom template page but got white page
- How to set max users to 17.000
- Facebook like update status for wordpress
- Custom Taxonomy Link Text Echo Name Not Slug
- WordPress will suddenly stop saving files uploaded by my code (ran in nopriv ajax)
- Permission error on plugin save
- Adding javascript files to WordPress and jQuery version
- Display default WordPress login/registration form into a modal window
- WP Login Button for current domain
- Pull GET parameter from URL in functions.php
- How to NOT override inline css rules
- Adding Gravity Form With if(is_page) Is Not Working
- Implement “No related posts for this entry” into the loop?
- Twig+WordPress how to use array arguments inside a function?
- I would like to alert message while another user is editing or update data in wordpress admin panel, what should i do?
- redirect user from login page if is logged
- How to set variable to specific field when querying
- How to lock users account until approvation
- WooCommerce: write featured image dimensions to custom fields in product’
- transition_post_status hook, works – but not if the post is new