correct validate inputs
Try $name = trim( sanitize_user( $_POST[‘name’], true ) ); Be sure that the function does what you want! Read here
Try $name = trim( sanitize_user( $_POST[‘name’], true ) ); Be sure that the function does what you want! Read here
You can also try below code to retrieve count of rows. $myquery = $wpdb->get_results( “SELECT * FROM tablename WHERE ID=’some-value'” ); echo $wpdb->num_rows; Let me know if you have any problem. cheers
I check your query and it’s working fine without any errors or empty results. But in addition if you remove INNER JOIN from wp_terms table its also working because you are not getting anything from that table and it is not used in WHERE clause also. SELECT ID, `post_date` , `post_title` , `post_content` , `guid` … Read more
I think you should run this query. To replace space with dash. update wp_posts set wp_posts.post_name = REPLACE( wp_posts.post_name, ‘ ‘, ‘-‘ ); Don’t forget to change table_prefix in this. And also, keep a backup on current database before trying.
I hope I understand the question correctly UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, ‘old_value’, ‘new_value’) WHERE `meta_key` LIKE ‘your_key’ EDIT 1 : i forgot to mention : BACKUP YOUR DATABASE BEFORE ANY TRIAL EDIT 2 : following comment : To copy from one field to another (I got a bit confused with your naming and … Read more
Can you verify that $_POST[‘name’] is obtaining a value. I suggest echoing it out to the page for debugging (maybe in comment tags if site is live). If $_POST[‘name’] is empty, then all results will be returned because the query will say user_nicename LIKE ‘%’ Just as a precaution in any case, you should do … Read more
Sorry Guys I’ve created a array $table_names and used $table_name in my sql statements. thanks!
$Featured_image = $wpdb->get_results(” SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = ‘_thumbnail_id’ ORDER BY p.post_date DESC LIMIT 15 “,’ARRAY_A’); A related solution, to query for posts WITHOUT providing a post ID (ordered by post date, and using the wp_ database prefix): SELECT p1.*, … Read more
$html= “<table>”; foreach($result as $r){ $html .=”<tr>”; $html .=”<td>”.$r->post_title.”</td>”; $html .=”<td><a href=””.get_the_permalink($r->ID)””>”.$r->post_title.”</a></td>”; $html .=”</tr>”; } $html .=”</table>”; echo $html; To avoid the depreacated usage of PHP code snippets you can wrap it in a shortcode and use anywhere in a page/post content editor function Stack_308511_post_grid( $atts ) { $atts = shortcode_atts( array( ‘limit’ => 10, … Read more
function delete_posts() { $lastposts = get_posts(array(‘numberposts’ => -1)); if ( $lastposts ) { foreach ( $lastposts as $post ) : setup_postdata( $post ); ?> <?php $content = get_the_content(); if (str_word_count($content) < 100) { wp_trash_post($post->ID); } ?> <?php endforeach; wp_reset_postdata(); }}add_action( ‘init’, ‘delete_posts’ );