Tag Info

Hot answers tagged

2

<?php $args = array( 'posts_per_page' => -1, 'post_type' => 'event', 'meta_query' => array( array( 'key' => 'event_date_end_timestamp', 'value' => time(), 'type' => 'numeric', 'compare' => '<' ) ) ); $programs = new WP_Query($args); ?> ...


2

parse_query is where the majority of the work is done. Query vars and is_ conditionals are set, and template-loader.php just checks those is_ conditional tags to load the appropriate template.


2

In addition to Milo's answer: In wp::parse_request() the request URI is matched against the rewrite rules stored in $GLOBALS[ 'wp_rewrite' ]->rules. That means, the »route« will be parsed into query variables. The actual matching rule is stored in $GLOBALS[ 'wp_rewrite' ]->matches which is quite helpful for debugging: add_action( 'wp_footer', ...


2

Before I start, do not use get_posts for paginated queries. get_posts legally breaks pagination, and does not return the query object. If you need to paginate queries, use WP_Query As for your issue, I really don't think limiting the total overall amount of posts to only 100 is possible when you involve pagination. The only scenarios I can think of is: ...


2

You have a couple of issues here the_content() echos the content to screen. You should be using get_the_content() which returns the content. Just remember, get_the_content() is unfiltered, so if you need filtered content, use apply_filters( 'the_content', get_the_content() ) which will return filtered content. Your explode() function is probably wrong as ...


1

Try "bootstrapping" WordPress for your custom script first: include '../../../wp-load.php' (you might need to adjust the path for your needs). Then you can safely use the $wpdb class, such as $wpdb->get_results and other goodies. Don't forget to escape/clean your incoming data, if any. WordPress documentation on $wpdb PS: always try to use "builtin" ...


1

Maybe it helps function wpcodex_filter_main_search_post_limits( $limit, $query ) { return 'LIMIT 0, 100'; } add_filter( 'post_limits', 'wpcodex_filter_main_search_post_limits', 10, 2 ); More: post_limits filter


1

As you have stated, rank is defined by a value in a custom field, so you would just need to get the value from the custom field and display it. You can try the following inside your loop global $post; // Just make sure the custom field name is correct $rank = get_post_meta( $post->ID, 'custom_field', true ); // Display the title and rank echo 'Rank ' ...


1

I notice that to link to each post, I am calling get_permalink() and this is creating an extra DB query for each post. Not true. If you check the link to the very old trac ticket #18822 in the post that you have linked to, this issue was raised by @kaiser in 2011. The question was answered by @scribu For example: $posts = get_posts(); foreach ( ...


1

As already hinted by @Milo, check if you have terms before appending your tax_query You can try the following: (Requires PHP 5.4+ due to short array syntax, revert to old syntax if necessary) $args = [ 'post_type' => 'product', 'posts_per_page' => 15, 'paged' => $paged, 'post__not_in' => $exclude, 's' => $filter, ]; // ...



Only top voted, non community-wiki answers of a minimum length are eligible