Support » Plugin: Ajax WP Query Search Filter » Problem using $post->post_title in loop = blank

  • 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?

Viewing 1 replies (of 1 total)
  • Plugin Author TC.K


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

Viewing 1 replies (of 1 total)
  • The topic ‘Problem using $post->post_title in loop = blank’ is closed to new replies.