Created
February 13, 2019 21:50
-
-
Save moxdev/063624315cf6e0f03521e9b5d09f1f4f to your computer and use it in GitHub Desktop.
Displaying Custom Post Types with Taxonomy on Archive page #wp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'pre_get_posts', 'quantum_custom_property_archives' ); | |
/** | |
* For displaying 'properties' custom post type on the 'property_location' taxonomy pages | |
* '-1' means unlimited number of custom posts will be displayed | |
* change '-1' to '5' to limit the number shown to 5 for pagination views | |
* | |
* @link https://wpsites.net/web-design/customize-archive-pages-conditionally-using-pre-get-posts/ | |
* @param [type] $query Custom query. | |
* @return void | |
*/ | |
function quantum_custom_property_archives( $query ) { | |
if ( ! is_admin() && is_post_type_archive( 'properties' ) || ! is_admin() && is_tax( 'property_locations' ) ) { | |
$query->set( 'posts_per_page', '-1' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment