将图像放置在帖子内容之间

时间:2017-05-03 09:34:57

标签: php wordpress wordpress-theming

我正在wordpress网站上工作,我的查询是我想在每个段落后的帖子内容中放置三个图像。我知道可以通过使用wordpress提供的文本编辑器来完成,但几天后我们将更改图像,在我的博客中我有50多篇文章,我不想继续每篇文章并改变图像有时间。那么有什么代码我可以在每个paragrapph之后为所有三个图像放置。这是我在主题中找到的代码。

<div class="<?php echo implode( ' ', apply_filters( 'hu_single_entry_class', array('entry','themeform') ) ) ?>">
    <div class="entry-inner">
     <?php the_content(); ?>
</div>
</div>

请建议我怎么做。提前谢谢。

3 个答案:

答案 0 :(得分:0)

你必须把你的图像放在内容之后。然后把图像放在<?php the_content(); ?>之后。

修改 single.php

<div class="<?php echo implode( ' ', apply_filters( 'hu_single_entry_class', array('entry','themeform') ) ) ?>">
    <div class="entry-inner">
     <?php the_content(); ?>
<img src="imagelink here" alt="" height="" width="">
<img src="imagelink here" alt="" height="" width="">
<img src="imagelink here" alt="" height="" width="">
</div>
</div>

答案 1 :(得分:0)

If you want add common 3 images on every post (i.e `single.php`)

    then you can use like this

    <div class="<?php echo implode( ' ', apply_filters( 'hu_single_entry_class', array('entry','themeform') ) ) ?>">
        <div class="entry-inner">
         <?php the_content(); ?>
    <a href=""><img class="img-responsive" src="" alt=""></a>
    <a href=""><img class="img-responsive" src="" alt=""></a>
    <a href=""><img class="img-responsive" src="" alt=""></a>
    </div>
    </div>

    If you want change the images in future so you can change the path here.

    If you want different images on each post so you can do it by suing advance custom field (`ACF`)

    Link- https://wordpress.org/plugins/advanced-custom-fields/

    By using create field and fetch on `single.php` page

    for fetching image use 

    <?php $field = get_field($field_name, $post_id, $format_value); ?>

    I hope this will help you.

    Thank you.

答案 2 :(得分:0)

i think you can do this by using Advance custom field. (ACF)

    Steps find below:

    1.create a field for content (the content before image) on single .php
    2.create image field by using ACF or reapter field and fetch in on single.php page
    3.create a field for content(the content after images) on single .php

    You can fetch both the conetnt field and images here so for every post you have to ad content but for images you can chnages the images once so it will reflect to your all post.

    I hope this will you.

    Thank you
相关问题