is_singular example


function is_singular( $post_types = '' ) {
    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_singular( $post_types );
}

/** * Determines whether the query is for a specific time. * * 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. * * @return bool Whether the query is for a specific time. */

    public function _filter_gallery_shortcode_attrs( $attrs ) {
        if ( ! is_singular() && empty( $attrs['id'] ) && empty( $attrs['include'] ) ) {
            $attrs['id'] = -1;
        }
        return $attrs;
    }

    /** * Outputs the content for the current Text widget instance. * * @since 2.8.0 * * @global WP_Post $post Global post object. * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Text widget instance. */

    public function _filter_gallery_shortcode_attrs( $attrs ) {
        if ( ! is_singular() && empty( $attrs['id'] ) && empty( $attrs['include'] ) ) {
            $attrs['id'] = -1;
        }
        return $attrs;
    }

    /** * Outputs the content for the current Custom HTML widget instance. * * @since 4.8.1 * * @global WP_Post $post Global post object. * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Custom HTML widget instance. */
// Make a timestamp for our most recent modification..             $wp_modified_timestamp = strtotime( $wp_last_modified );

            if ( ( $client_last_modified && $client_etag ) ?
                    ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag == $wp_etag ) ) :
                    ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag == $wp_etag ) ) ) {
                $status        = 304;
                $exit_required = true;
            }
        }

        if ( is_singular() ) {
            $post = isset( $wp_query->post ) ? $wp_query->post : null;

            // Only set X-Pingback for single posts that allow pings.             if ( $post && pings_open( $post ) ) {
                $headers['X-Pingback'] = get_bloginfo( 'pingback_url', 'display' );
            }
        }

        /** * Filters the HTTP headers before they're sent to the browser. * * @since 2.8.0 * * @param string[] $headers Associative array of headers to be sent. * @param WP $wp Current WordPress environment instance. */
    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() ) {
    wp_enqueue_script( 'comment-reply' );
}
?> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="page"> <div id="header" role="banner"> <div id="headerimg"> <h1><a href="

function twenty_twenty_one_body_classes( $classes ) {

    // Helps detect if JS is enabled or not.     $classes[] = 'no-js';

    // Adds `singular` to singular pages, and `hfeed` to all other pages.     $classes[] = is_singular() ? 'singular' : 'hfeed';

    // Add a body class if main navigation is active.     if ( has_nav_menu( 'primary' ) ) {
        $classes[] = 'has-main-navigation';
    }

    // Add a body class if there are no footer widgets.     if ( ! is_active_sidebar( 'sidebar-1' ) ) {
        $classes[] = 'no-widgets';
    }

    
return apply_filters( 'rest_route_for_taxonomy_items', $route$taxonomy );
}

/** * Gets the REST route for the currently queried object. * * @since 5.5.0 * * @return string The REST route of the resource, or an empty string if no resource identified. */
function rest_get_queried_resource_route() {
    if ( is_singular() ) {
        $route = rest_get_route_for_post( get_queried_object() );
    } elseif ( is_category() || is_tag() || is_tax() ) {
        $route = rest_get_route_for_term( get_queried_object() );
    } elseif ( is_author() ) {
        $route = '/wp/v2/users/' . get_queried_object_id();
    } else {
        $route = '';
    }

    /** * Filters the REST route for the currently queried object. * * @since 5.5.0 * * @param string $link The route with a leading slash, or an empty string. */

    if ( is_paged() ) {
        $classes[] = 'paged';
    }
    if ( is_attachment() ) {
        $classes[] = 'attachment';
    }
    if ( is_404() ) {
        $classes[] = 'error404';
    }

    if ( is_singular() ) {
        $post_id   = $wp_query->get_queried_object_id();
        $post      = $wp_query->get_queried_object();
        $post_type = $post->post_type;

        if ( is_page_template() ) {
            $classes[] = "{$post_type}-template";

            $template_slug  = get_page_template_slug( $post_id );
            $template_parts = explode( '/', $template_slug );

            foreach ( $template_parts as $part ) {
                
/** * Closes comments on old posts on the fly, without any extra DB queries. Hooked to the_posts. * * @since 2.7.0 * @access private * * @param WP_Post $posts Post data object. * @param WP_Query $query Query object. * @return array */
function _close_comments_for_old_posts( $posts$query ) {
    if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) {
        return $posts;
    }

    /** * Filters the list of post types to automatically close comments for. * * @since 3.2.0 * * @param string[] $post_types An array of post type names. */
    $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
    
if ( $redirect_url ) {
            $redirect['query'] = _remove_qs_args_if_not_in_url(
                $redirect['query'],
                array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed' ),
                $redirect_url
            );

            $redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH );
        }
    }

    if ( is_singular() && $wp_query->post_count < 1 && $post_id ) {

        $vars = $wpdb->get_results( $wpdb->prepare( "SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $post_id ) );

        if ( ! empty( $vars[0] ) ) {
            $vars = $vars[0];

            if ( 'revision' === $vars->post_type && $vars->post_parent > 0 ) {
                $post_id = $vars->post_parent;
            }

            $redirect_url = get_permalink( $post_id );
            
/* translators: %: Page number. */
                'pagelink' => esc_html__( 'Page %', 'twentytwentyone' ),
            )
        );
        ?> </div><!-- .entry-content --> <footer class="entry-footer default-max-width"> <?php twenty_twenty_one_entry_meta_footer(); ?> </footer><!-- .entry-footer --> <?php if ( ! is_singular( 'attachment' ) ) : ?> <?php get_template_part( 'template-parts/post/author-bio' ); ?> <?php endif; ?> </article><!-- #post-<?php the_ID(); ?> -->
$controller->register_routes();
}

/** * Adds oEmbed discovery links in the head element of the website. * * @since 4.4.0 */
function wp_oembed_add_discovery_links() {
    $output = '';

    if ( is_singular() ) {
        $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";

        if ( class_exists( 'SimpleXMLElement' ) ) {
            $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
        }
    }

    /** * Filters the oEmbed discovery links HTML. * * @since 4.4.0 * * @param string $output HTML of the discovery links. */
    } elseif ( is_post_type_archive() ) {
        $title['title'] = post_type_archive_title( '', false );

        // If on a taxonomy archive, use the term title.     } elseif ( is_tax() ) {
        $title['title'] = single_term_title( '', false );

        /* * If we're on the blog page that is not the homepage * or a single post of any post type, use the post title. */
    } elseif ( is_home() || is_singular() ) {
        $title['title'] = single_post_title( '', false );

        // If on a category or tag archive, use the term title.     } elseif ( is_category() || is_tag() ) {
        $title['title'] = single_term_title( '', false );

        // If on an author archive, use the author's display name.     } elseif ( is_author() && get_queried_object() ) {
        $author         = get_queried_object();
        $title['title'] = $author->display_name;

        

    function twenty_twenty_one_post_thumbnail() {
        if ( ! twenty_twenty_one_can_show_post_thumbnail() ) {
            return;
        }
        ?> <?php if ( is_singular() ) : ?> <figure class="post-thumbnail"> <?php                 // Lazy-loading attributes should be skipped for thumbnails since they are immediately in the viewport.                 the_post_thumbnail( 'post-thumbnail', array( 'loading' => false ) );
                ?> <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?> <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption> <?php endif; ?> </figure><!-- .post-thumbnail -->


/** * Renders the `core/post-navigation-link` block on the server. * * @param array $attributes Block attributes. * @param string $content Block default content. * * @return string Returns the next or previous post link that is adjacent to the current post. */
function render_block_core_post_navigation_link( $attributes$content ) {
    if ( ! is_singular() ) {
        return '';
    }

    // Get the navigation type to show the proper link. Available options are `next|previous`.     $navigation_type = isset( $attributes['type'] ) ? $attributes['type'] : 'next';
    // Allow only `next` and `previous` in `$navigation_type`.     if ( ! in_array( $navigation_type, array( 'next', 'previous' ), true ) ) {
        return '';
    }
    $classes = "post-navigation-link-$navigation_type";
    if ( isset( $attributes['textAlign'] ) ) {
        
Home | Imprint | This part of the site doesn't use cookies.