I am working on a template for a custom post type (books) in which I am calling a list of authors that come from another custom post type (people). They are linked through the plugin Posts 2 Posts.
My Aim is to create a sequence of authors separated by comma, like this: Author1, Author2, Author3, Author4.
With the code below, the result is a sequence of authors like this : Author1Author2Author3Author4. The same code also works to get a list of elements by adding a li division below the_post();, with this results :
The piece of code :
echo ‘<b>Autores: </b>’;
while ( $autores->have_posts() ) : $autores->the_post();
echo ‘<a href=”‘;
Maybe this question can be answered in multiple forms. One is by converting this object into an array of elements (I don’t know how…yet?). At least, I found a very useful method which works with taxonomy elements (here: https://wordpress.stackexchange.com/a/238362), but this is not working in my case, maybe because I have one object, so when I make a count($autores) I always have 1 as result.
I also wonder if it is possible to use css to convert a list of elements into inline elements and separate them with commas.
I will really appreciate if someone here can give me an idea to resolve this question. Keep searching by my side…