Avoiding page loop

I would highly recommend you to make one of those wp query calls the main query & all others as secondary queries. That will make your life much easier in the long run. If you absolutely want to disable the main query, wordpress doesn’t have a direct filter for that. You can however do a … Read more

Modify query after meta value

Here’s an example using WP_Query‘s meta_query to query posts between two meta key values: $meta_query = array( array( ‘key’ => ‘event_date’, ‘value’ => array( $date_start, $date_end ), ‘compare’ => ‘BETWEEN’ ) ); $args = array( ‘posts_per_page’ => -1, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value’, ‘meta_query’ => $meta_query ); $results = new WP_Query( $args );

Query specific number of posts for each post type in specific order

You can use WP_Query() with paged array key to pass the current page number: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘articles’, ‘posts_per_page’ => 4, ‘paged’ => $paged ); $articles = new WP_Query($args); //////////////////////////////// $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 1, ‘meta_query’ => array( array( ‘key’ => … Read more

Custom search: Search posts but display parent page in results

Ok I have figured it out; added the following to functions.php: add_filter( ‘posts_request’, ‘my_request_filter’, 10, 2 ); function my_request_filter($sql, $query) { if($query->is_main_query() && is_search()) { $sql = “SELECT * FROM wp_posts WHERE post_content LIKE ‘[smoothslider%’ AND post_parent !=’0′”; } return $sql; } I understand that with no access to the database or being able to … Read more

Displaying content to search engines but via navigation only for registered users.

You can detect where the user comes from (like Google) using HTTP_REFERER. <?php if (strpos($_SERVER[‘HTTP_REFERER’], “google”) == true) { echo “Hello Google User!”; } ?> So for your logged-in user: <?php if ( current_user_can( ‘subscriber’ ) && strpos( $_SERVER[‘HTTP_REFERER’], ‘google’ ) ) { ?> [content here] <?php } ?> Important Links wp_get_referer()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)