I am creating a widget and it works fine now, but the code doesn't seem terribly efficient.
In the widget function, I'm calling another function in the same class. That function returns a string.
In that function, I have created a WP_Query object and then iterate it [while ($my_query->have_posts()) : $my_query->the_post();]
The problem line is the next line, the line to create the string. Previously, when the code was in the widget function, I used the_permalink and get_title to get those strings, but they won't work now because they echo the value. Instead I'm using this line of code:
$mystring .= '
That seems inefficient when I've already gotten the $post object. Any ideas on how to make this better?
Also, I tried $post->post_title in place of the get_the_title call and that didn't work. All I need is the permalink and the title.