如何删除"编辑此条目"?

时间:2016-06-14 08:58:09

标签: php wordpress

我正在尝试删除以下行

<p><?php edit_post_link(__('Edit this entry','express'),''); ?></p>

来自以下代码的其余部分:

<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 &#187;','express'), __('One Comment &#187;','express'), __('% Comments &#187;','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>

我打算使用&#34;编辑此条目&#34;链接在底部,其余代码在页面顶部。但是当我删除

if ( is_singular() || is_page() ) { ?>
    <p><?php edit_post_link(__('Edit this entry','express'),''); ?></p>
<?php } ?>

我的Wordpress分页符。它应该是语法错误,但我找不到将这部分代码与其他代码分开的正确方法。

任何想法将不胜感激。 感谢

1 个答案:

答案 0 :(得分:0)

您不小心删除了一些必须留下的标签。

if ( is_singular() || is_page() ) { ?>&lt; - 这个必须留下来

试试这个:

<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 &#187;','express'), __('One Comment &#187;','express'), __('% Comments &#187;','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>