The page that displays Posts on homepage

The way you are thinking wordpress is, is not like that. You can’t find the query and alter it like you do in plain PHP. There are filters and actions and a whole architecture to play with pages and posts. I suggest you to read wordpress documentation and Codex. If you are a programmer then … Read more

SQL command to export post_content from wp_posts using phpMyAdmin

Use This Script <?php $servername = “localhost”; $username = YOUR_USER; $password = YOUR_PASSWORD; $dbname = YOUR_DB_NAME; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die(“Connection failed: ” . $conn->connect_error); } $a1 = ($_GET[‘id’]); $sql = “SELECT post_content FROM `wp_posts` where ID=’$a1′”; $result = $conn->query($sql); if ($result->num_rows > … Read more

SQL query add only posts with custom field to array

Why don’t you just do: <?php global $post; $args = array( ‘post_type’ => ‘post’, ‘post_status’ = ‘publish’, ‘posts_per_page’ => ’10’, ‘meta_query’ => array( array( ‘key’ => ‘fruit’, ‘value’ => ‘apple’ ) ) ); $custom_query = new WP_Query( $args ); while( $custom_query->have_posts() ): $custom_query->the_post(); ?> <?php the_title(); ?> <?php endwhile; wp_reset_query(); ?>

query using wpdb in wordpress gets me no result

First of all, you escape that query incorrectly… You should use esc_like on the like part and prepare should be used a little bit different: $title1 = ‘Gocomma 10W QI Wireless Fast Charger Car Mount Holder – 2pcs (it)’; $sql = $wpdb->prepare( “SELECT * FROM {$wpdb->posts} WHERE post_title LIKE %s AND post_status=”publish””, ‘%’ . $wpdb->esc_like($title1) … Read more

wpdb prepare without placeholder

Short answer: You should use the way described in the documentation, sanitize anything that goes in an SQL query, and always use prepared statements. Slightly longer answer: The main use of $wpdb->prepare() is to prevent against SQL injection attacks. Here, we don’t know where ‘foo’, 1337 and ‘%bar’ come from. And that’s somewhat the deciding … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)