如何在WordPress中为一个假人定制帖子


How to make custom posts in WordPress for a dummy?

我想知道的是,我如何实现我已经制作好的index.php文件来应用自定义帖子。(见下文)

我想要实现的目标:

Display all posts(already accomplished in index.php)
--> show normal post a.k.a 'Article' (already accomplished in index.php)
If category/or post type 'Aside' is used, don't apply a <a> tag, make title lighter(can figure it out in CSS)
-->show text for the 'Aside' marked post
If category/or post type 'Link' is used,  wrap title in <a> tag linking to a site(<-- how would I do that in WordPress?)  
-->show text for info about the link
If category/or post type 'Photo' is used, don't wrap title in a <a> tag
-->show attached image in post, and post text as a caption

我知道这看起来可能很多,但我相信这很容易做到。

有些源代码可能对我没有帮助,所以我在下面有我的index.php,看看你是否可以帮助我实现它:

<?php get_header(); ?>

<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
            <article>
            <!-- <p><span class="metaCat"><?php the_category(', '); ?></span></p> -->
            <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
            <p><span class="meta"><?php the_time('F jS, Y') ?></span></p>
            <hr />
            <div class="entry">
                <?php the_content('Read the rest of this entry &raquo;'); ?>
            </div>
        </div>
</article>
        <hr class="big" />
    <?php endwhile; ?>

<?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>

如果你能将所需的代码输入到一个可行的index.php文件中,你就会得到一些深思熟虑的分数!

谢谢,欢迎所有帮助!

我终于明白你想在这里做什么了。使用get_post_format()函数可以很容易地做到这一点。只需将此处的标题替换为:

<?php
$format = get_post_format(get_the_ID());
if ($format == 'link') { ?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php  the_title(); ?>"><?php the_title(); ?></a></h1>
<?php }else{ ?>
    <h1><?php the_title(); ?></h1>
<?php } ?>

不过,关于链接到网站的另一点,我不确定你想如何实现。你指的是博客吗?

"链接"帖子格式的最佳选择是使用自定义元盒/自定义字段。将密钥添加为"URL",然后在值字段中键入地址。

使用get_post_meta()获取URL,并在href中使用该URL而不是the_permalink()