So I have been trying to have a index.php do three things.
If there is a thumbnail to show the thumbnail and do the specific styling.
if there isn't a thumbnail do something different
and the last statement will have if the page is singular it will show something else.
For some reason it keeps failing. I've seen some demos on here, but i can't figure it out
<?php /** this is the first if statement **/?>
<?php if ( is_home () || is_category() || is_archive() ): ?>
<?php if ( has_post_thumbnail() ) { ?>
<article class="blog-card" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php optz_post_thumbnail(); ?>
<?php
if ( is_singular() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif;
if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta">
</div><!-- .entry-meta -->
<?php
endif; ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
the_excerpt( sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'optz' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
) );
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'optz' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
optz_posted_on();
optz_posted_by();
?>
<?php optz_entry_footer(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php /** this is the first second else statement **/ elseif (is_home () || is_category() || is_archive()) :>
<article class="blog-card" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php
the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta">
</div><!-- .entry-meta -->
<?php
endif; ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php
the_content( sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'optz' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
) );
wp_link_pages( array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'optz' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
optz_posted_on();
optz_posted_by();
?>
<?php optz_entry_footer(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php /** this is the first last if else statement **/ }else :{?>
<p>Nothing to see</p>
<?php endif; ?>
<?php } ?> <!-- this is the main php thumbnail close tag --!>
Aucun commentaire:
Enregistrer un commentaire