我從頭開始開發Wordpress自定義主題。我設法讓自定義網格顯示在index.php中工作。每個帖子都會顯示一個圖片,其中的帖子標題和類別爲副標題。這裏是index.php的代碼:WordPress的永久鏈接沒有鏈接到content.php
<?php get_header(); ?>
<div class="container-fluid bg-3 text-center Site-content" style="padding:60px; padding-top:100px;">
<?php
$counter = 1; //start counter
$grids = 2; //Grids per row
query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');
if (have_posts()) : while (have_posts()) : the_post();
?>
<?php
//Show the left hand side column
if ($counter == 1) :
?>
<div class="col-sm-4">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php the_post_thumbnail_url(); ?>" class="img-responsive" style="width:100%;" alt=""></a>
<strong><?php the_title(); ?></strong>
<?php
foreach ((get_the_category()) as $category) {
echo "<h6>".$category->category_nicename. "</h6>";
}
?>
</div>
<?php
//Show the right hand side column
elseif ($counter == $grids) :
?>
<div class="col-sm-4">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php the_post_thumbnail_url(); ?>" class="img-responsive" style="width:100%;" alt=""></a>
<strong><?php the_title(); ?></strong>
<?php
// heres just the name and permalink:
foreach ((get_the_category()) as $category) {
echo "<h6>".$category->category_nicename. "</h6>";
}
?>
</div>
<?php
$counter = 0;
endif;
?>
<?php
$counter++;
endwhile;
endif;
?>
</div>
<?php get_footer(); ?>
帖子的縮略圖包含一個鏈接到這篇文章的永久鏈接,應該鏈接到content.php。這裏的content.php:
<div class="container" style="padding:100px;">
\t <strong><?php the_title(); ?></strong>
<?php
foreach ((get_the_category()) as $category) {
echo "<h5>" . $category->category_nicename . "</h5>";
}
?>
<h5>/<?php the_date(); ?> </h5>
<h5> <?php the_content(); ?> </h5>
</div>
的問題是,當我點擊縮略圖的index.php,它鏈接到自身的縮小版,而不是content.php頁面。我的猜測是,我需要告訴固定鏈接去哪裏,但我無法真正找到放置該配置的位置。
謝謝!
它工作完美,謝謝!現在,我只是無法將我的外部CSS表應用於生成的內容,但我想這是另一回事。 – rschpdr