Foreach only outputs if id is 0
I actually found the issue. It was in the foreach I found the issue where I had an unnecessary sql-query that i removed.
I actually found the issue. It was in the foreach I found the issue where I had an unnecessary sql-query that i removed.
It’s not complicated to connect to custom tables in WP context and query them, using native wpdb class. However “not complicated” is about all there it. WP API functions are primarily aimed at querying its own data structures. While wpdb does have some helpers, they are simplistic and not meant for more elaborate custom queries. … Read more
You need to have the table prefix set in the wp-config.php file. It must be matching the same value in tables of your database, the default value is “wp_” but if you used a customized value for your tables to enhance security which is a good practice, you need to update your $table_prefix = ‘wp_’; … Read more
You can access WordPress data using WordPress REST API. If you want to know how to use the REST API from a React Native app, then give a read to this article.
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
$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
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’ );
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
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”));
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