Tag Info

Hot answers tagged

6

I've never seen it done before but the logic of the PHP IF/ELSE should mean you could simply plug a new query in after the ELSE: if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part ( 'templates/post', 'main' ); endwhile; else: $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( ...


2

The custom properties you refer to are dates which a stored in a custom table, and which are joined onto the query for events. At this point in time, when querying events, this table is only joined when only the 'event' post type is being queried. That is, you can search for events - but the dates are only pulled in if you are searching only for events. ...


2

There is no conditional tag for no results on a search page, but you can create yourself one. You basically just have to check the value of $wp_query->found_posts, if it is 0, returns false, any other value, returns true function is_search_has_results() { global $wp_query; $result = ( 0 != $wp_query->found_posts ) ? true : false; return ...


1

It is actually pretty annoying to bend WP_Query for it. However there is convenient get_page_by_title() function that can do just that. Despite the name it allows you to pass other post types as third argument.



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