我目前正在開發一個mutlisite wordpress設置,每個網站是不同的語言(EG:site.com,site.dk等)。WordPress的 - 帖子和頁面
這些網站由多個包含靜態內容的頁面組成,但是我也想將帖子(一個博客)包括到這兩個網站中。
Q1。是否有可能創建一個頁面,顯示按最新發布日期列出的所有帖子,以及按類別過濾的下拉列表?我該怎麼做呢?我需要引用loop.php嗎?
基本上它應該返回所有文章文章下面的代碼...
<article class="post">
<a href="<URL Link to Post Article>" rel="bookmark">
<figure>
<img title="<Post Title>" alt="<Post Title>" src="<http://url/PostImage.jpg>" width="900" height="600" />
</figure>
<div class="cover">
<h2>Post Title</h2>
<time pubdate="2013-03-27T21:09:59+00:00">November 18, 2012</time>
</div>
</a>
</article>
爲什麼不這項工作?它不會返回任何東西?
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article class="post">
<?php get_posts(); ?>
<div id="grid-switcher">
<a href="#" data-block="featured-posts" id="featured">featured</a>
<a href="#" data-block="latest-posts" id="latest" class="active">latest</a>
</div>
<div id="view-blocks">
<div id="latest-post" class="post-grid active">
<?php if (has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(array(250,250)); // Declare pixel size you need inside the array ?>
<?php endif; ?>
<!-- /post thumbnail -->
<div class="cover">
<h2><?php the_title(); ?></h2>
<time pubdate="<?php the_date(); ?>"><?php the_date('Y-m-d', '<h2>', '</h2>'); ?></time>
</div>
</a>
我已經創建了一個頁面模板投資組合page.php文件對上述而是通過帖子不能findout如何循環並與上面的代碼返回呢? Q2302。如何返回所有類別的下拉列表?
Q3。如何從下拉列表中按類別過濾?
感謝您的幫助! :)
對不起,我是新來的PHP和WordPress ...
對不起,我試圖讓問題少模糊... – myatix
@myatix您使用get_posts在一個循環,我不知道該頁是否存在..請檢查該函數的手冊頁(答案中有一個鏈接)..你會看到他們使用返回值的foreach語句迭代結果,而不是作爲「循環「 – mishu
即使我使用」帶偏移量的帖子列表「示例它不起作用?我有一個頁面模板的代碼...它是否需要在loop.php文件中,或者我可以直接在頁面模板中引用它?對不起,正如我所說我對此很新... – myatix