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

  1. pixelkicks
    Posted 2 years 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?


  2. TC.K
    Plugin Author

    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Ajax WP Query Search Filter
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic