I am trying to remove the following lines
<p><?php edit_post_link(__('Edit this entry','express'),''); ?></p>
from the rest of the following code:
<section class="postmetadata clearfix">
<?php
if ( !is_page() && !is_attachment() ) {
$options = get_option( 'express_theme_options' );
$time = '<time datetime=' . get_the_time('Y-m-d') . '>' . get_the_time('j F Y') . '</time>';
$categories = get_the_category_list( __(', ', 'express') );
$tags = get_the_tag_list( __('and tagged ', 'express'),', ' );
$author_name = get_the_author_meta('display_name');
$author_ID = get_the_author_meta('ID');
$author_link = '<a href="' . get_author_posts_url($author_ID) . '">' . $author_name . '</a>';
$author = sprintf( __( 'by %s', 'express' ), $author_link );
if ( isset( $options['post-author'] ) && $options['post-author'] ) {
if ( is_singular() ) {
$postmeta = __('Posted in %1$s on %2$s %3$s %4$s', 'express');
} elseif ( 'chat' == get_post_format() ) {
$postmeta = __( 'Filed under %1$s %2$s %3$s', 'express' );
} elseif ( 'gallery' == get_post_format() || 'image' == get_post_format() ) {
$postmeta = __( 'Displayed in %1$s %2$s %3$s', 'express' );
} else {
$postmeta = __('Posted in %1$s %2$s %3$s', 'express');
}
} else {
if ( is_singular() ) {
$postmeta = __('Posted in %1$s on %2$s %3$s', 'express');
} elseif ( 'chat' == get_post_format() ) {
$postmeta = __( 'Filed under %1$s %2$s', 'express' );
} elseif ( 'gallery' == get_post_format() || 'image' == get_post_format() ) {
$postmeta = __( 'Displayed in %1$s %2$s', 'express' );
} else {
$postmeta = __('Posted in %1$s %2$s', 'express');
}
}
if ( is_singular() ) {
printf( $postmeta, $categories, $time, $tags, $author );
} else {
printf( $postmeta, $categories, $tags, $author );
}
?>
<br />
<?php
if ( comments_open() ) :
echo '<p>';
comments_popup_link(__('No Comments »','express'), __('One Comment »','express'), __('% Comments »','express'), __('Comments are closed.', 'express'));
echo '</p>';
endif;
?>
<?php } elseif ( is_attachment() ) {
$imagemeta = wp_get_attachment_metadata();
$time = '<time datetime=' . get_the_time('Y-m-d') . '>' . get_the_time('j F Y') . '</time>';
$image_url = wp_get_attachment_url();
$parent_title = get_the_title( $post->post_parent );
$parent_link = '<a href="' . get_permalink( $post->post_parent ) . '" title="' . sprintf( __( 'Permalink to %s', 'express' ), esc_attr( $parent_title ) ) . '">' . esc_attr( $parent_title ) . '</a>';
printf( __( 'Attached to %1$s which was posted on %2$s.' , 'express' ), $parent_link, $time );
echo '<br />';
echo '<a href="' . esc_url_raw( $image_url ) . '" title="' . __( 'Link to full-size image.', 'express' ) . '">';
_e( 'View full image.', 'express' );
echo '</a>';
}
if ( is_singular() || is_page() ) { ?>
<p><?php edit_post_link(__('Edit this entry','express'),''); ?></p>
<?php } ?>
</section>
I intend to use the "edit this entry" link at the bottom and the rest of the code right at the top of the page. But when I remove the
if ( is_singular() || is_page() ) { ?>
<p><?php edit_post_link(__('Edit this entry','express'),''); ?></p>
<?php } ?>
my Wordpress page breaks. It should be a syntax error, but I cannot find the right way to separate this part of the code from others.
Any ideas will be appreciated. Thanks
You accidentally deleted some tags that have to stay.
if ( is_singular() || is_page() ) { ?>
<- this one has to stay
Try this:
<section class="postmetadata clearfix">
<?php
if ( !is_page() && !is_attachment() ) {
$options = get_option( 'express_theme_options' );
$time = '<time datetime=' . get_the_time('Y-m-d') . '>' . get_the_time('j F Y') . '</time>';
$categories = get_the_category_list( __(', ', 'express') );
$tags = get_the_tag_list( __('and tagged ', 'express'),', ' );
$author_name = get_the_author_meta('display_name');
$author_ID = get_the_author_meta('ID');
$author_link = '<a href="' . get_author_posts_url($author_ID) . '">' . $author_name . '</a>';
$author = sprintf( __( 'by %s', 'express' ), $author_link );
if ( isset( $options['post-author'] ) && $options['post-author'] ) {
if ( is_singular() ) {
$postmeta = __('Posted in %1$s on %2$s %3$s %4$s', 'express');
} elseif ( 'chat' == get_post_format() ) {
$postmeta = __( 'Filed under %1$s %2$s %3$s', 'express' );
} elseif ( 'gallery' == get_post_format() || 'image' == get_post_format() ) {
$postmeta = __( 'Displayed in %1$s %2$s %3$s', 'express' );
} else {
$postmeta = __('Posted in %1$s %2$s %3$s', 'express');
}
} else {
if ( is_singular() ) {
$postmeta = __('Posted in %1$s on %2$s %3$s', 'express');
} elseif ( 'chat' == get_post_format() ) {
$postmeta = __( 'Filed under %1$s %2$s', 'express' );
} elseif ( 'gallery' == get_post_format() || 'image' == get_post_format() ) {
$postmeta = __( 'Displayed in %1$s %2$s', 'express' );
} else {
$postmeta = __('Posted in %1$s %2$s', 'express');
}
}
if ( is_singular() ) {
printf( $postmeta, $categories, $time, $tags, $author );
} else {
printf( $postmeta, $categories, $tags, $author );
}
?>
<br />
<?php
if ( comments_open() ) :
echo '<p>';
comments_popup_link(__('No Comments »','express'), __('One Comment »','express'), __('% Comments »','express'), __('Comments are closed.', 'express'));
echo '</p>';
endif;
?>
<?php } elseif ( is_attachment() ) {
$imagemeta = wp_get_attachment_metadata();
$time = '<time datetime=' . get_the_time('Y-m-d') . '>' . get_the_time('j F Y') . '</time>';
$image_url = wp_get_attachment_url();
$parent_title = get_the_title( $post->post_parent );
$parent_link = '<a href="' . get_permalink( $post->post_parent ) . '" title="' . sprintf( __( 'Permalink to %s', 'express' ), esc_attr( $parent_title ) ) . '">' . esc_attr( $parent_title ) . '</a>';
printf( __( 'Attached to %1$s which was posted on %2$s.' , 'express' ), $parent_link, $time );
echo '<br />';
echo '<a href="' . esc_url_raw( $image_url ) . '" title="' . __( 'Link to full-size image.', 'express' ) . '">';
_e( 'View full image.', 'express' );
echo '</a>';
}
?>
</section>