jessicasalmon / em-illustrator

custom Word Press theme for Emily McGovern's illustration and comic website
0 stars 0 forks source link

[feature] build category page #14

Closed jessicasalmon closed 7 years ago

jessicasalmon commented 7 years ago

using wordpress loop. See page-portfolio.php in treehouse-portfolio

jessicasalmon commented 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' );
jessicasalmon commented 7 years ago

https://code.tutsplus.com/articles/applying-categories-tags-and-custom-taxonomies-to-media-attachments--wp-32319

https://casabona.org/2014/12/add-attachments-wordpress-search-results/