Closed jessicasalmon closed 7 years ago
closing due to change of approach: I can use posts & custom post types. See new issue #18
Attempted solutions to display attachments by category below. Neither showed categories to category.php, but both outputted test input to all pages.
attempt 1:
function search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_category() ) {
$query->set('post_type', array( 'post', 'attachments' ) );
}
}
echo "test";
}
add_action('pre_get_posts','search_filter');
attempt 2:
function attachment_search( $query ) {
if ( $query->is_search() ) {
$query->set( 'post_type', array( 'post', 'attachment' ) );
$query->set( 'post_status', array( 'publish', 'inherit' ) );
}
return $query;
}
echo "test";
add_filter( 'pre_get_posts', 'attachment_search' );
using wordpress loop. See page-portfolio.php in treehouse-portfolio