2017-02-09 24 views
1

我試圖在Marketify主題的帖子標題下移動帖子的精選圖片,但是我似乎無法在代碼中找到隱藏的東西。如何在Marketify單個帖子下移動標題下方的精選圖片

任何人都可以幫我找到帖子特色圖片的代碼嗎?我如何在帖子標題下移動它?

+0

這取決於什麼主題的開發者稱他們的模板文件。作爲一個起點,你的主題目錄中是否有一個名爲'single.php'的文件?通常,在'/ wp-content/themes/[theme-name] – Craig

回答

0

首先,爲您的WordPress主題創建一個Child Theme

然後查看'/ wp-content/themes/[主題名],在那裏你應該找到一個名爲'single.php'的文件。將其複製到您的子主題中,注意確保您複製相同的目錄層次結構。 'single.php'通常是您的默認博客帖子模板的名稱。

使用Notepad ++等程序打開'single.php'文件,該文件保存在您的子主題中。(記事本也可以,但不是那麼容易)。

你應該看到:

<?php if (has_post_thumbnail()) { 
     the_post_thumbnail(); 
    }?> 
    <?php 
    if (have_posts()) : 
     while (have_posts()) : the_post(); ?> 

      <h1><?php the_title(); ?></h1> //This is the title of your Blog Post. 

      <div class="entry"> 
      <?php the_content(); ?> //This is the content of your Blog Post. 
      </div> 

     <?php endwhile; ?> 
    <?php endif; ?> 

會有在編碼略有變化,但你在找什麼做的是亮點:

<?php if (has_post_thumbnail()) { 
     the_post_thumbnail(); 
}?> 

然後將這個編碼到下方<h1><?php the_title(); ?></h1>。你需要在你需要的地方玩耍,但我希望這能幫助你開始。

我建議你在Child Theme中這樣做的原因是,當Theme Developer推出更新時,它會刪除你在父文件中所做的任何修改。

祝你好運!

0

感謝您的評論。我認爲它與你寫的代碼很相似,但標題和精選圖片隱藏在「do_action('marketify_entry_before');」中。

get_header(); ?> 

    <?php do_action('marketify_entry_before'); ?> 

    <div class="container"> 
    <div id="content" class="site-content row"> 

     <div role="main" id="primary" class="col-xs-12 col-md-8 <?php echo ! is_active_sidebar('sidebar-1') ? 'col-md-offset-2' : '' ?>"> 
      <main id="main" class="site-main" role="main"> 

      <?php if (have_posts()) : ?> 

       <?php while (have_posts()) : the_post(); ?> 

        <?php get_template_part('content', 'single'); ?> 
        <?php comments_template(); ?> 

       <?php endwhile; ?> 

儘管如此,爲別人同樣的問題;我想出如何隱藏這部分的CSS是這樣的...

.single .header-outer.has-image .page-header { 
     display: none; 
    } 

然後可以使用標準的WordPress的功能,使標題和特色形象出現在那裏我想要的。

謝謝:)

湯姆

相關問題