String concatenation in Wordpress String concatenation in Wordpress wordpress wordpress

String concatenation in Wordpress


the_permalink() and the_title() does not return anything they are to print values.

You have to use their get_ version. Those are get_permalink() and get_the_title()

<?php $str .= '<a href="' . get_permalink() . '">' .get_the_title() . '</a>'; ?>


This is more of a wordpress question, but you should be using get_permalink() and get_the_title() instead of the functions you have there. Those functions will echo the link and title, and not return it in string form for use in your concatenation.