Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #527064

    I want to add an extra class to the image that appears on the single page of a blog post.
    What file do I need to edit for that?

    I want to use animate css to add an animation.
    Or is there another way to add a fade in to an image?

    #527140
    #527263

    Thanks!

    This is nice to to do when I want just one element animated. But when I can add the classes to the image in the templates (php), I would not need to do this manually every time.

    Where can I add the classes to the image for the blog listing page and the blog single page?
    I can’t seem to find the right php files…

    • This reply was modified 9 years, 1 month ago by zenimot.
    #527925

    Hi!

    Not sure I understand. Can you send us a link to the exact page and take a screenshot highlighting the exact images your referring to?

    Best regards,
    Elliott

    #528487

    The blog page is: http://typischroos.nl/wpmapje/typischetips/
    I’ve got this page working, so that every blog image has a fade in animation.
    This I’ve changed in a template file.

    But as you go to a single blog page e.g. http://typischroos.nl/wpmapje/voor-en-na/
    I want that main image to be animated also.
    At the moment I’ve got this working by adding extra classes to the image in the blog interface.

    But I want this animation working, by changing the template file, so I don’t have to manually add to classes to an image every time.

    #528977

    Hey!

    I’m sorry but I don’t think this is possible because you added the images as content. The template file for the single post page is the includes > loop-index.php file and the whole content resides in this line of code:

    // echo the post content
                echo $content_output;
    

    EDIT: Try to add the class attribute via jQuery: https://api.jquery.com/addclass/

    Best regards,
    Ismael

    #529223

    Thanks.
    I’ve tried this, but can’t get it working. :(

    #529762

    Hey!

    Are you going to add the effect for every image inside the post? Try this in the functions.php file:

    // add class
    function add_custom_script(){
    ?>
    <script>
    (function($) {
    	$('.single .entry-content').find('img').each(function() {
    		$(this).addClass('animated fadeInUp');
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Cheers!
    Ismael

    #529855

    THANKS! That did the trick.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Add custom class to image on single blog page’ is closed to new replies.