首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要帮助从自定义WP主题更改预先制作的博客帖子格式。

需要帮助从自定义WP主题更改预先制作的博客帖子格式。
EN

Stack Overflow用户
提问于 2013-09-26 20:47:36
回答 1查看 261关注 0票数 0

我从Codestag的Themeforest购买了一个名为Shift的WP主题,它是一个非常容易使用和干净的UI。它主要是为博客风格的文章,他们已经创建了预先制作的博客文章风格.

例如," audio“帖子是文本和嵌入的音频文件。“视频”是视频链接和文字,“照片”显然是照片和文本。

我的问题是,这些都是不可定制的,我创建的博客文章类型要么是音频,要么是视频,包括艺术家的照片或相册艺术。我需要添加哪些代码来允许这个预先制作的帖子包含一张照片?(代码如下)

第二个问题是如何将顺序从音频文件、标题、文本更改为标题、图片文本和音频?

这是预先制作的博客样式的代码:"Audio"

代码语言:javascript
复制
<div class="hentry-inner">

  <div class="entry-wrapper grids">

<?php get_template_part('content', 'meta'); ?>

<div class="entry-content grid-10 clearfix">

  <?php
  $embed = get_post_meta(get_the_ID(), '_stag_audio_embed', true);

  if(!empty($embed)){
    echo do_shortcode(htmlspecialchars_decode($embed));
  }else{
    stag_audio_player(get_the_ID());
  }

  ?>

  <?php if( is_single() ) { ?>

    <h1 class="entry-title"><?php the_title(); ?></h1>

  <?php } else { ?>

    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'stag'), get_the_title()); ?>"> <?php the_title(); ?></a></h2>
  <?php } ?>

  <?php

    if(!is_singular()){
      if(get_the_excerpt() != '') echo "<p>".strip_shortcodes(get_the_excerpt())."</p>";
    }else{
      the_content(__('Continue Reading', 'stag'));
      wp_link_pages(array('before' => '<p><strong>'.__('Pages:', 'stag').'</strong> ',   'after' => '</p>', 'next_or_number' => 'number'));
    }

  ?>
</div>
 <span class="bottom-accent"></span>
  </div>
</div>

非常感谢您的帮助!-Peter

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-28 07:10:55

在这里,我添加了the_post_thumbnail (参见Codex),以显示内容上方的照片:

代码语言:javascript
复制
<div class="hentry-inner">

    <div class="entry-wrapper grids">

        <?php get_template_part('content', 'meta'); ?>

        <div class="entry-content grid-10 clearfix">

            <?php
            $embed = get_post_meta(get_the_ID(), '_stag_audio_embed', true);

            if(!empty($embed)){
                echo do_shortcode(htmlspecialchars_decode($embed));
            }else{
                stag_audio_player(get_the_ID());
            }

            ?>

            <?php if( is_single() ) { ?>

            <h1 class="entry-title"><?php the_title(); ?></h1>

            <?php } else { ?>

            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'stag'), get_the_title()); ?>"> <?php the_title(); ?></a></h2>
            <?php } ?>

            <?php

            if(!is_singular()){
                if(get_the_excerpt() != '') echo "<p>".strip_shortcodes(get_the_excerpt())."</p>";
            }else{

                if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                    the_post_thumbnail();
                } 

                the_content(__('Continue Reading', 'stag'));

                wp_link_pages(array('before' => '<p><strong>'.__('Pages:', 'stag').'</strong> ',   'after' => '</p>', 'next_or_number' => 'number'));
            }

            ?>
        </div>
        <span class="bottom-accent"></span>
    </div>
</div>

此模板显示标题、特征图像、内容、音频(按顺序排列):

代码语言:javascript
复制
<div class="hentry-inner">

    <div class="entry-wrapper grids">

        <?php get_template_part('content', 'meta'); ?>

        <div class="entry-content grid-10 clearfix">

            <h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'stag'), get_the_title()); ?>"> <?php the_title(); ?></a></h2>

            <?php

            if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
                the_post_thumbnail();
            }

            the_content(__('Continue Reading', 'stag'));

            wp_link_pages(array('before' => '<p><strong>'.__('Pages:', 'stag').'</strong> ',   'after' => '</p>', 'next_or_number' => 'number'));

            $embed = get_post_meta(get_the_ID(), '_stag_audio_embed', true);

            if(!empty($embed)){
                echo do_shortcode(htmlspecialchars_decode($embed));
            }else{
                stag_audio_player(get_the_ID());
            }

            ?>

        </div>
        <span class="bottom-accent"></span>
    </div>
</div>

WordPress有很好的文档,我建议您深入WordPress码。如果您需要进一步的自定义,您可能应该要求和/或雇用主题作者为您做修改。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19038392

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档