$wpdb->prepare returns empty array

Try with: function getComponents($page_id, $currentLanguage) { global $wpdb; $result = $wpdb->get_results($wpdb->prepare( ” SELECT id, post_content, post_title, post_excerpt, post_name, m1.meta_value AS ‘template’, m2.meta_value AS ‘home_description’ FROM {$wpdb->posts} p JOIN wp_term_relationships r ON p.ID = r.object_id JOIN wp_terms t ON r.term_taxonomy_id = t.term_id WHERE t.slug=%s AND post_parent = %d AND post_type=”page” AND post_status=”publish” ORDER BY menu_order ASC … Read more

Delete posts with word count less than x number of words

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’ );

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

$wpdb->insert not working for last select option

The ID can’t be empty. If you have created your table and set your ID as auto increment, you don’t have to insert it, it will be generated automatically. So all you have to do is the following: $result = $wpdb->insert(‘pagos’, array( “nombre” => $nombre, “tipo” => $tipo, “monto” => $monto), array(“%s”, “%s”, “%d”));

Multiple Address In WP-Option Value

After testing for hours, finally get it done. Here the solution: In database wp_options change the value for siteurl and home from your wordpress url to /path/to/wordpress WordPress URL Path To WordPress Then add these code in the bottom of wp-config.php define(‘WP_HOME’, ‘http://’ .$_SERVER[‘HTTP_HOST’].”https://wordpress.stackexchange.com/”); define(‘WP_SITEURL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . “https://wordpress.stackexchange.com/” ); Now you can use … Read more