0

I was writing my custom blog page for wordpress

I replaced my content.php with this code

<?php
/**
 * Template part for displaying posts.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Trevelle
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php the_title( sprintf( '<h3class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?>

        <?php if ( 'post' === get_post_type() ) : ?>
        <div class="post-details">
          <i class="fa fa-clock-o"></i><time><?php the_date(); ?></time>
        <i class="fa fa-folder-open"></i> <a href=""><?php the_category(', '); ?></a>
        <?php edit_post_link('Edit', '<div><i class="fa fa-penicil"></i>', '</div>'); ?>
                    </div>
        <?php endif; ?>
    </header><!-- .entry-header -->
<?php if (has_post_thumbnail() ) : { ?>
    <div class="post-image">
 <?php the_post_thumbnail(); ?>
    </div>
    <?php } ?>

    <div class="post-excerpt">
      <?php the_excerpt(); ?>
    </div>

</article><!-- #post-## -->

and everything except header and was gone. I was unable to see any post and sidebars.

I replaced it back with the original which is

<?php
/**
 * @package GovPress
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>

        <?php if ( 'post' == get_post_type() ) : ?>
        <div class="entry-meta">
            <?php govpress_posted_on(); ?>
        </div><!-- .entry-meta -->
        <?php endif; ?>
    </header><!-- .entry-header -->

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
        <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'govpress' ) ); ?>
        <?php
            wp_link_pages( array(
                'before' => '<div class="page-links">' . __( 'Pages:', 'govpress' ),
                'after'  => '</div>',
            ) );
        ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    <footer class="entry-meta">
        <ul class="entry-meta-taxonomy">
        <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
            <?php echo get_the_category_list('<li>','</li><li>','</li>'); ?>
            <?php echo get_the_tag_list('<li>','</li><li>','</li>'); ?>
        <?php endif; // End if 'post' == get_post_type() ?>

            <?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
            <li class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'govpress' ), __( '1 Comment', 'govpress' ), __( '% Comments', 'govpress' ) ); ?></li>
            <?php endif; ?>

            <?php edit_post_link( __( 'Edit', 'govpress' ), '<li class="edit-link">', '</li>' ); ?>
        </ul>
    </footer><!-- .entry-meta -->

</article><!-- #post-## -->

Now I am seeing only one post heading this Hello World

Can't see anything. I have refresh the page several times. Applied Ctrl +F5 cleaned cache and history and infact change the browser but no help.

  • You have a syntax error in your code, turn debug on and read what the error message say – Pieter Goosen Dec 4 '15 at 11:25
  • Parse error: syntax error, unexpected end of file in /home/abiglitt/public_html/trevelle/wp-content/themes/trevelle/template-parts/content.php on line 35 Ok This is the error I am getting while using my own code. – Dennis Dec 4 '15 at 11:25
  • Parse error: syntax error, unexpected end of file in /home/abiglitt/public_html/trevelle/wp-content/themes/trevelle/template-parts/content.php on line 35 – Dennis Dec 4 '15 at 11:29
  • 2
    You cannot mix syntax, if you start with if () :, then you need to end with endif, not with a curly bracket. You also cannot use both at the same time like if () : { and then } endif – Pieter Goosen Dec 4 '15 at 11:29
  • 1
    Also, while we are at it, please read What should I do when someone answers my question?, then revisit your other posts and leave feedback as described in the link – Pieter Goosen Dec 4 '15 at 11:33
0

Credit goes to @PieterGoosen

You cannot mix syntax, if you start with if () :, then you need to end with endif, not with a curly bracket. You also cannot use both at the same time like if () : { and then } endif

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php the_title( sprintf( '<h3class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?>

        <?php if ( 'post' === get_post_type() ) : ?>
        <div class="post-details">
          <i class="fa fa-clock-o"></i><time><?php the_date(); ?></time>
        <i class="fa fa-folder-open"></i> <a href=""><?php the_category(', '); ?></a>
        <?php edit_post_link('Edit', '<div><i class="fa fa-penicil"></i>', '</div>'); ?>
                    </div>
        <?php endif; ?>
    </header><!-- .entry-header -->
<?php if (has_post_thumbnail() ) : { ?>
    <div class="post-image">
 <?php the_post_thumbnail(); ?>
    </div>
    <?php } endif ?>

    <div class="post-excerpt">
      <?php the_excerpt(); ?>
    </div>

</article><!-- #post-## -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.