• I’m displaying some blog posts and when I click on a link I’m trying to bring in other blog categories using AJAX. This all works great and this is the code I have to do that:

    $.ajax({
    url: ajaxurl,
    type: "POST",
    async: true,
    cache: true,
    data: {
    action: 'show_blog',
    term_id: term_id
    },
    success: function(data) {
    //we have the data now
    $('.blog-wrapper').fadeOut(1000, function() {
    //this is a callback once the element has finished hiding
    //populate the div with whatever was returned from the ajax call
    $('.blog-wrapper').html(data);
    //fade in with new content
    $(".blog-wrapper").fadeIn(1000);
    });
    }
    });

    This is my function to call the shortcode:

    function show_blog() {
        global $wpdb; // this is how you get access to the database
        $content = '[blog_zip number_posts="3" cat_slug="29" title="yes" thumbnail="yes" excerpt="yes" excerpt_words="25" meta_all="yes" meta_author="yes" meta_categories="yes" meta_comments="yes" meta_date="yes" meta_link="yes" paging="yes" scrolling="infinite" strip_html="no" layout="medium alternate" zip_code="60601,60605,60602"][/blog_zip]';
        $content = apply_filters('the_content', $content);
        echo $content;
    }

    This brings back the blog post text correctly but it doesn’t display any images. Is there something else I need to do to get the images to be displayed correctly?

Viewing 1 replies (of 1 total)
  • Thread Starter treeleaf20

    (@treeleaf20)

    The images are actually returned in the HTML but they aren’t displayed. Some of the other formatting is also lost I noticed

Viewing 1 replies (of 1 total)

The topic ‘Images aren't Displayed when using AJAX’ is closed to new replies.