How to make attachment tag archive visible on page


I want to make my images displayed on archive by tags, but found only this code:

add_action('parse_query', 'hijack_query');
function hijack_query() {
    global $wp_query;
    // When inside a custom taxonomy archive, include attachments AS WELL AS pages and posts.
    // Note that is_tax() returns false on category archives and tag archives. Use is_category() and is_tag() respectively when checking for category and tag archives.

    if (is_tax('topic') OR is_tax('training') OR is_tag() OR is_category()) {
        $wp_query->query_vars['post_type'] =  array( 'attachment', 'page', 'post' );
        $wp_query->query_vars['post_status'] =  array( null );
        return $wp_query;

And it’s not enough.

I used to make archive visible using this code, combined with another, but can’t find the second one on google, and I don’t remember how it worked.

Can you help me make attachment tag archive on page?

birgire 1 week 2023-01-20T11:29:46-05:00 0 Answers 0 views 0

Leave an answer