簡體   English   中英

如何修復在 WordPress 主題中不起作用的永久鏈接

[英]How to fix a Permalink that is not working in WordPress theme

我有一個 WordPress “管”主題。 當我單擊縮略圖時,它會打開一個新頁面,這是我的主頁。 (它應該帶我到帖子頁面)但我可以手動輸入帖子頁面地址到 go 那里? 我怎樣才能在代碼中解決這個問題。 這是 image.php 中的一段代碼。 我知道一些 PHP 但不是很流利,所以我不能完全連接點。

<header class="entry-header">
                <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>

                <div class="entry-meta">

                    <span class="entry-date"><time class="entry-date" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time></span>

                    <span class="full-size-link"><a href="<?php echo esc_url( wp_get_attachment_url() ); ?>"><?php echo esc_html( $metadata['width'] ); ?> &times; <?php echo esc_html( $metadata['height'] ); ?></a></span>

                    <span class="parent-post-link"><a href="<?php echo esc_url( get_permalink( $post->post_parent ) ); ?>" rel="gallery"><?php echo get_the_title( $post->post_parent ); ?></a></span>
                    <?php edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' ); ?>
                </div><!-- .entry-meta -->
            </header><!-- .entry-header -->

您需要鏈接到實際的帖子鏈接。

也許嘗試更換

post->post_parent 

和:

post->ID

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM