is_attachment example

$post_password_required = post_password_required( $post->ID );

    // Post requires password.     if ( $post_password_required ) {
        $classes[] = 'post-password-required';
    } elseif ( ! empty( $post->post_password ) ) {
        $classes[] = 'post-password-protected';
    }

    // Post thumbnails.     if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) {
        $classes[] = 'has-post-thumbnail';
    }

    // Sticky for Sticky Posts.     if ( is_sticky( $post->ID ) ) {
        if ( is_home() && ! is_paged() ) {
            $classes[] = 'sticky';
        } elseif ( is_admin() ) {
            $classes[] = 'status-sticky';
        }
    }

    
if ( $redirect_url ) {
                $redirect['query'] = _remove_qs_args_if_not_in_url(
                    $redirect['query'],
                    array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ),
                    $redirect_url
                );
            }
        }
    } elseif ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) {

        // Rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101.         if ( is_attachment()
            && ! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) )
            && ! $redirect_url
        ) {
            if ( ! empty( $_GET['attachment_id'] ) ) {
                $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
                $redirect_obj = get_post( get_query_var( 'attachment_id' ) );

                if ( $redirect_url ) {
                    $redirect['query'] = remove_query_arg( 'attachment_id', $redirect['query'] );
                }
            } else {
                

function is_attachment( $attachment = '' ) {
    global $wp_query;

    if ( ! isset( $wp_query ) ) {
        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
        return false;
    }

    return $wp_query->is_attachment( $attachment );
}

/** * Determines whether the query is for an existing author archive page. * * If the $author parameter is specified, this function will additionally * check if the query is for one of the authors specified. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 1.5.0 * * @global WP_Query $wp_query WordPress Query object. * * @param int|string|int[]|string[] $author Optional. User ID, nickname, nicename, or array of such * to check against. Default empty. * @return bool Whether the query is for an existing author archive page. */


get_header();

/* Start the Loop */
while ( have_posts() ) :
    the_post();

    get_template_part( 'template-parts/content/content-single' );

    if ( is_attachment() ) {
        // Parent post navigation.         the_post_navigation(
            array(
                /* translators: %s: Parent post link. */
                'prev_text' => sprintf( __( '<span class="meta-nav">Published in</span><span class="post-title">%s</span>', 'twentytwentyone' ), '%title' ),
            )
        );
    }

    // If comments are open or there is at least one comment, load up the comment template.     if ( comments_open() || get_comments_number() ) {
        

function twenty_twenty_one_can_show_post_thumbnail() {
    /** * Filters whether post thumbnail can be displayed. * * @since Twenty Twenty-One 1.0 * * @param bool $show_post_thumbnail Whether to show post thumbnail. */
    return apply_filters(
        'twenty_twenty_one_can_show_post_thumbnail',
        ! post_password_required() && ! is_attachment() && has_post_thumbnail()
    );
}

/** * Returns the size for avatars used in the theme. * * @since Twenty Twenty-One 1.0 * * @return int */
function twenty_twenty_one_get_avatar_size() {
    

function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
    $post = get_post();
    if ( $previous && is_attachment() && $post ) {
        $post = get_post( $post->post_parent );
    } else {
        $post = get_adjacent_post( $in_same_term$excluded_terms$previous$taxonomy );
    }

    if ( empty( $post ) ) {
        return;
    }

    $post_title = the_title_attribute(
        array(
            
/** * Filters the post excerpt for the embed template. * * Shows players for video and audio attachments. * * @since 4.4.0 * * @param string $content The current post excerpt. * @return string The modified post excerpt. */
function wp_embed_excerpt_attachment( $content ) {
    if ( is_attachment() ) {
        return prepend_attachment( '' );
    }

    return $content;
}

/** * Enqueues embed iframe default CSS and JS. * * Enqueue PNG fallback CSS for embed iframe for legacy versions of IE. * * Allows plugins to queue scripts for the embed iframe end using wp_enqueue_script(). * Runs first in oembed_head(). * * @since 4.4.0 */
Home | Imprint | This part of the site doesn't use cookies.