query_posts works while get_posts doesn’t

Every page has a “main query” which is run before the template is loaded. The results of the main query are how WordPress determines what template to load. The standard Loop operates on the data contained in the main query, this is why it seems to just magically “work” without you having to explicitly query … Read more

how to ask if in two categorys inside if

You can specify multiple categories within has_category like so: if ( has_category( array( ‘category_1’, ‘category_2’ ) ) { // do something } However, I am not sure if this acts as AND or OR, meaning does it require that ALL categories specified are matched, or one of the X supplied (category_1 OR category_2). In any … Read more

Efficiently loop over huge number of posts

Call a external script: Your function look like this: <?php function modify_posts() { $number_posts = 10; $offset = 0; $success=”success”; while ( ‘success’ === $success ) { $url = add_query_arg( array( ‘num’ => $number_posts, ‘off’ => $offset, ‘abs’ => urlencode( ABSPATH ) ), plugins_url( ‘remote_get.php’, __FILE__ ) ); $response = wp_remote_get( $url ); if ( … Read more