Replace Unwanted Space in Post Content URL

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.

How to get EVENT based on startday, using BETWEEN

found the solution <3 Used WHERE ‘$startday’ BETWEEN dstart AND dend plus : OR dstart >= ‘$startday’ SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status=”publish” AND wp_icl_translations.language_code=”$lang” AND (‘$startday’ BETWEEN dstart AND dend OR dstart >= ‘$startday’) AND wp_posts.ID = wp_icl_translations.element_id ORDER BY dstart LIMIT 0,6

SQL – JOIN last child

This is the solution I came up with: SELECT child_ID, posts.post_author, wp1.post_author FROM wp_posts posts LEFT JOIN ( SELECT MAX(ID) as child_ID, post_parent FROM wp_posts WHERE post_type=”ticket_reply” GROUP BY post_parent ) sl ON posts.ID = sl.post_parent INNER JOIN wp_posts wp1 on sl.child_ID = wp1.ID WHERE posts.ID = 1499

Creating a “forum” – showing last post or last commented post

You can add the standard taxonomy joins to the query: global $wpdb; $cat_id = 79; // Whatever. $sql = ” select wp_posts.*, coalesce( ( select max(comment_date) from $wpdb->comments wpc where wpc.comment_post_id = wp_posts.id ), wp_posts.post_date ) as mcomment_date from $wpdb->posts wp_posts JOIN $wpdb->term_relationships AS tr ON wp_posts.ID = tr.object_id JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id … Read more

Sql query returns empty. But not

If you can answer ‘yes’ to the questions in Emetrop’s comment, then try: $sql = $wpdb->get_results(‘SELECT * from table1 WHERE id = $bransId’);

Insert multiple checkbox values

I solve it. public function insertionRow($id){ global $wpdb; $wpdb->query(“INSERT INTO wp_choix_attributs_liste (att_id) VALUES (“.$id.”);”); } In my html with the checkbox. if(isset($_POST[‘sub’])) { foreach ($_POST[‘choixP’] as $id) { self::insertionRow($id); } }

Analog category_and (WP) in sql query

Thanks Milo for the answer! This block of code selects posts that have two categories at the same time. ( ( SELECT COUNT(1) FROM wp_term_relationships WHERE term_taxonomy_id IN (35,33) AND object_id = wp_posts.ID ) = 2 ) Where 35,33 are categories IDs and 2 – number of categories.