因此,我試圖讓我們的WordPress博客在我們基於HTML的網站的不同頁面上展示。我做了大量的研究,我有一個很好的想法,我應該如何繼續(我認爲),但我不認爲我拉動正確的Loop代碼來做到這一點。
的頁面是在這裏:www.cidermag.com/blog.php
正如你可以看到,該網站會返回「一無所獲」的值,即使我們有大約三四個測試樁已通過公佈WP儀表板。但是,我得到了Loop的這一部分返回的事實給了我希望我在正確的軌道上......
根據我在網上找到的說明,我從index.php中提取循環代碼文件位於我們的/ blog/wp-content/themes/twentytwelve文件夾中。我知道我必須爲特定的事物編制具體的價值觀,但我現在只需要至少讓博客展示,所以我有一個理解這個野獸的起點。 (我的學習效果比閱讀好。)
任何援助將不勝感激,因爲我似乎無法找到明確的答案。謝謝!
的循環PHP代碼:
<?php require('blog/wp-blog-header.php'); ?>
<?php if (have_posts()) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php get_template_part('content', get_post_format()); ?>
<?php endwhile; ?>
<?php twentytwelve_content_nav('nav-below'); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<?php if (current_user_can('edit_posts')) :
// Show a different message to a logged-in user who can add posts.
?>
<header class="entry-header">
<h1 class="entry-title"><?php _e('No posts to display', 'twentytwelve'); ?></h1>
</header>
<div class="entry-content">
<p><?php printf(__('Ready to publish your first post? <a href="%s">Get started here</a>.', 'twentytwelve'), admin_url('post-new.php')); ?></p>
</div><!-- .entry-content -->
<?php else :
// Show the default message to everyone else.
?>
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'twentytwelve'); ?></h1>
</header>
<div class="entry-content">
<p><?php _e('Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve'); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
<?php endif; // end current_user_can() check ?>
</article><!-- #post-0 -->
<?php endif; // end have_posts() check ?>
請張貼一些培訓相關的PHP代碼,以幫助您與您的問題 – Schleis
你的博客的網址是什麼? http://cidermag.com/blog/?我在那裏看到帖子。你有沒有設置主題?爲什麼你給我們的URL以.php結尾? –
/博客是我們安裝WP(每條指令)的位置。但是,因爲這不是一個WP網站,所以我們讀的所有內容都需要用.php擴展名重命名HTML頁面。因此頁面的URL。我們沒有設定任何主題,因爲訪問者的最終目標是永遠不會看到WP默認頁面 - 只有我們HTML網站上的帖子。 – user2612650