is_single example


function is_single( $post = '' ) {
    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_single( $post );
}

/** * Determines whether the query is for an existing single post of any post type * (post, attachment, page, custom post types). * * If the $post_types parameter is specified, this function will additionally * check if the query is for one of the Posts Types 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 * * @see is_page() * @see is_single() * @global WP_Query $wp_query WordPress Query object. * * @param string|string[] $post_types Optional. Post type or array of post types * to check against. Default empty. * @return bool Whether the query is for an existing single post * or any of the given post types. */

function adjacent_posts_rel_link_wp_head() {
    if ( ! is_single() || is_attachment() ) {
        return;
    }
    adjacent_posts_rel_link();
}

/** * Displays the relational link for the next post adjacent to the current post. * * @since 2.8.0 * * @see get_adjacent_post_rel_link() * * @param string $title Optional. Link title format. Default '%title'. * @param bool $in_same_term Optional. Whether link should be in the same taxonomy term. * Default false. * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * Default empty. * @param string $taxonomy Optional. Taxonomy, if `$in_same_term` is true. Default 'category'. */

    function twenty_twenty_one_entry_meta_footer() {

        // Early exit if not a post.         if ( 'post' !== get_post_type() ) {
            return;
        }

        // Hide meta information on pages.         if ( ! is_single() ) {

            if ( is_sticky() ) {
                echo '<p>' . esc_html_x( 'Featured post', 'Label for sticky posts', 'twentytwentyone' ) . '</p>';
            }

            $post_format = get_post_format();
            if ( 'aside' === $post_format || 'status' === $post_format ) {
                echo '<p><a href="' . esc_url( get_permalink() ) . '">' . twenty_twenty_one_continue_reading_text() . '</a></p>'; // phpcs:ignore WordPress.Security.EscapeOutput             }

            // Posted on.
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 {
                $redirect_url = get_attachment_link();
                $redirect_obj = get_post();
            }
        } elseif ( is_single() && ! empty( $_GET['p'] ) && ! $redirect_url ) {
            $redirect_url = get_permalink( get_query_var( 'p' ) );
            $redirect_obj = get_post( get_query_var( 'p' ) );

            if ( $redirect_url ) {
                $redirect['query'] = remove_query_arg( array( 'p', 'post_type' )$redirect['query'] );
            }
        } elseif ( is_single() && ! empty( $_GET['name'] ) && ! $redirect_url ) {
            $redirect_url = get_permalink( $wp_query->get_queried_object_id() );
            $redirect_obj = get_post( $wp_query->get_queried_object_id() );

            if ( $redirect_url ) {
                
$m        = get_query_var( 'm' );
    $year     = get_query_var( 'year' );
    $monthnum = get_query_var( 'monthnum' );
    $day      = get_query_var( 'day' );
    $search   = get_query_var( 's' );
    $title    = '';

    $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary.
    // If there is a post.     if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
        $title = single_post_title( '', false );
    }

    // If there's a post type archive.     if ( is_post_type_archive() ) {
        $post_type = get_query_var( 'post_type' );
        if ( is_array( $post_type ) ) {
            $post_type = reset( $post_type );
        }
        $post_type_object = get_post_type_object( $post_type );
        if ( ! $post_type_object->has_archive ) {
            
printf( ent2ncr( __( 'Comments on: %s' ) )get_the_title_rss() );
    } elseif ( is_search() ) {
        /* translators: Comments feed title. 1: Site title, 2: Search query. */
        printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) )get_bloginfo_rss( 'name' )get_search_query() );
    } else {
        /* translators: Comments feed title. %s: Site title. */
        printf( ent2ncr( __( 'Comments for %s' ) )get_wp_title_rss() );
    }
    ?> </title> <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> <link><?php ( is_single() ) ? the_permalink_rss() : bloginfo_rss( 'url' ); ?></link> <description><?php bloginfo_rss( 'description' ); ?></description> <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate> <sy:updatePeriod> <?php         /** This filter is documented in wp-includes/feed-rss2.php */
        echo apply_filters( 'rss_update_period', 'hourly' );
    ?> </sy:updatePeriod> <sy:updateFrequency> <?php         /** This filter is documented in wp-includes/feed-rss2.php */
        
// Extract updated query vars back into global namespace.         foreach ( (array) $wp_query->query_vars as $key => $value ) {
            $GLOBALS[ $key ] = $value;
        }

        $GLOBALS['query_string'] = $this->query_string;
        $GLOBALS['posts']        = & $wp_query->posts;
        $GLOBALS['post']         = isset( $wp_query->post ) ? $wp_query->post : null;
        $GLOBALS['request']      = $wp_query->request;

        if ( $wp_query->is_single() || $wp_query->is_page() ) {
            $GLOBALS['more']   = 1;
            $GLOBALS['single'] = 1;
        }

        if ( $wp_query->is_author() ) {
            $GLOBALS['authordata'] = get_userdata( get_queried_object_id() );
        }
    }

    /** * Set up the current user. * * @since 2.0.0 */
<?php echo wp_get_document_title(); ?></title> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <?php if ( file_exists( get_stylesheet_directory() . '/images/kubrickbgwide.jpg' ) ) { ?> <style type="text/css" media="screen"> <?php     // Checks to see whether it needs a sidebar.     if ( empty( $withcomments ) && ! is_single() ) {
        ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbg-<?php bloginfo( 'text_direction' ); ?>.jpg") repeat-y top; border: none; } <?php } else { // No sidebar. ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?> </style> <?php } ?> <?php if ( is_singular() ) {
    

function comments_template( $file = '/comments.php', $separate_comments = false ) {
    global $wp_query$withcomments$post$wpdb$id$comment$user_login$user_identity$overridden_cpage;

    if ( ! ( is_single() || is_page() || $withcomments ) || empty( $post ) ) {
        return;
    }

    if ( empty( $file ) ) {
        $file = '/comments.php';
    }

    $req = get_option( 'require_name_email' );

    /* * Comment author information fetched from the comment cookies. */
if ( function_exists( 'mb_convert_encoding' ) ) {
    $title     = mb_convert_encoding( $titleget_option( 'blog_charset' )$charset );
    $excerpt   = mb_convert_encoding( $excerptget_option( 'blog_charset' )$charset );
    $blog_name = mb_convert_encoding( $blog_nameget_option( 'blog_charset' )$charset );
}

// Escape values to use in the trackback. $title     = wp_slash( $title );
$excerpt   = wp_slash( $excerpt );
$blog_name = wp_slash( $blog_name );

if ( is_single() || is_page() ) {
    $post_id = $posts[0]->ID;
}

if ( ! isset( $post_id ) || ! (int) $post_id ) {
    trackback_response( 1, __( 'I really need an ID for this to work.' ) );
}

if ( empty( $title ) && empty( $trackback_url ) && empty( $blog_name ) ) {
    // If it doesn't look like a trackback at all.     wp_redirect( get_permalink( $post_id ) );
    exit;
}
$numpages  = 1;
        $multipage = 0;
        $page      = $this->get( 'page' );
        if ( ! $page ) {
            $page = 1;
        }

        /* * Force full post content when viewing the permalink for the $post, * or when on an RSS feed. Otherwise respect the 'more' tag. */
        if ( get_queried_object_id() === $post->ID && ( $this->is_page() || $this->is_single() ) ) {
            $more = 1;
        } elseif ( $this->is_feed() ) {
            $more = 1;
        } else {
            $more = 0;
        }

        $content = $post->post_content;
        if ( str_contains( $content, '<!--nextpage-->' ) ) {
            $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
            $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
            
$template_slug  = get_page_template_slug( $post_id );
            $template_parts = explode( '/', $template_slug );

            foreach ( $template_parts as $part ) {
                $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) );
            }
            $classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
        } else {
            $classes[] = "{$post_type}-template-default";
        }

        if ( is_single() ) {
            $classes[] = 'single';
            if ( isset( $post->post_type ) ) {
                $classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id );
                $classes[] = 'postid-' . $post_id;

                // Post Format.                 if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
                    $post_format = get_post_format( $post->ID );

                    if ( $post_format && ! is_wp_error( $post_format ) ) {
                        $classes[] = 'single-format-' . sanitize_html_class( $post_format );
                    }
Home | Imprint | This part of the site doesn't use cookies.