0

Suppose I want to add some imagess in my all posts Eg. I want add this : <img src="ad.png" > after this text

That's all

every post

& that image should be different in different category.

0

I think you should use post-thumbnails

In your functions.php file
This function will give you access to add image on each post you want to add am image

//And post featured images
 function add_featured_image(){
    add_theme_support('post-thumbnails');
}
add_action("after_setup_theme", "add_featured_image");

After adding that function in your functions.php, now you can access the functionality in admin dashboard. By just creating a image post enter image description here

Now you can insert your image on each post you want.

But after inserting featured image in your post it won't show up immediately in your pages, what you will have to do in your index.php, or any name of your page your using.

<?php if(have_posts()):
?>
 <?php 
  while(have_posts()):the_post(); ?>
       <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
      <?php
         the_post_thumbnail();
         $words = implode(' ', array_slice(explode(' ', get_the_title()), 0, 3));
         if(get_the_title() == $words){
          the_title();
         }else{
          echo $words."...";
         }
         ?>
<?php endwhile; ?>
<?php 
else:
  _e('Sorry, no book has been posted yet!');
endif; ?>

This functionality will help you to see your image. Wherever you want it to be seen.

3
  • I think you can't get it ,I mean my all post contains That's all & In each post I want to add some image after text That's all – mhktricks.net Mar 3 '15 at 9:59
  • Can you add your source codes – Little Phild Mar 3 '15 at 12:27
  • I don't have any – mhktricks.net Mar 4 '15 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.