WordPress.org

Ready to get started?Download WordPress

Forums

Ajax WP Query Search Filter
Problem using $post->post_title in loop = blank (2 posts)

  1. pixelkicks
    Member
    Posted 10 months ago #

    I have some custom code that trims down the post title if its over so many characters, and this is the code that I use:

    if (strlen($post->post_title) > 40) {
            $trimmedtitle = substr($post->post_title, 0, 60) . '...'; } else {
            $trimmedtitle = $post->post_title;
        }

    This works fine when I view the listings/archive page without any ajax filters applied, and shows the post title correct.

    However when I filter the results, the post title comes back blank. Everything else displays ok though.

    If I change $trimmedtitle back to the_title(); then it works fine.

    Why doesn't this work when the results are pulled via ajax?

    http://wordpress.org/plugins/ajax-wp-query-search-filter/

  2. TC.K
    Member
    Plugin Author

    Posted 10 months ago #

    You can try use get_the_title($query->post->ID), or $query->post->post_title.

Reply

You must log in to post.

About this Plugin

About this Topic