创建单独的 WordPress 主页和博客

发布于 2024-11-27 23:09:29 字数 569 浏览 4 评论 0原文

您好,我想创建一个包含更新博客条目的主页。 4 个不同类别的标题列表

我想要一个具有不同模板的常规博客页面的链接。

现在,我刚刚更改了 index.php 以容纳特色帖子内容的容器。

所以这是一个由两部分组成的问题,我如何获得该事物的这些迷你更新 我想多次使用 query_posts() 并按类别分开。

如何创建一个可链接到 blog.php 文件的页面,该文件当前告诉我所有这些函数都未定义。

<?php get_header(); ?>

<?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 endif; ?>

<?php get_footer(); ?>

Hello I want to Create a home page that has updating blog entries.
So 4 lists of headlines from different categories

And I want to have a link to the regular blog page with a different template.

Right now I just changed index.php around to have the containers for the featured posts content.

So this is a two part question how do I get these mini updates for the thing
I want to use query_posts() multiple times I assume and separate by category.

And how do I make a linkable page to a blog.php file which currently is telling me that all these functions are undefined.

<?php get_header(); ?>

<?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 endif; ?>

<?php get_footer(); ?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人哭 2024-12-04 23:09:29

如果您想创建一个包含主题或博客文件夹之外的 WP 数据/帖子的页面,您需要首先包含并启用 Wordpress 功能:

    define('WP_USE_THEMES', false);
    require('./blog/wp-blog-header.php');

然后您可以按类别对每组帖子进行查询:

    $args = array( 'numberposts' => '5, 'offset'=> 1, 'category' => 'your category ID' );
    $myposts = get_posts( $args );
    foreach($myposts as $post) {
    ...some code...
    }

我希望如此有帮助。

If you want to create a page that includes WP data/posts outside the themes or blog folder, you need to include and make available the Wordpress functions first:

    define('WP_USE_THEMES', false);
    require('./blog/wp-blog-header.php');

And then you can make the queries for each set of posts by category:

    $args = array( 'numberposts' => '5, 'offset'=> 1, 'category' => 'your category ID' );
    $myposts = get_posts( $args );
    foreach($myposts as $post) {
    ...some code...
    }

I hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文