We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Display entries by author

How Do I?

restos's avatar
restos
54 posts
10 years ago
restos's avatar restos

Hi,

I’m trying to display entries by author. I’ve an issue because my template uses Masonry to generate entries and I need to display the author name outside {exp:channel:entries}, I need to get the name at the top of the page.

This is the code i use to generate entries with Masonry:

<div>NEED AUTHOR NAME HERE</div>

<div id="container-din">
        {exp:channel:entries channel="test" dynamic="no" order by="random" status="not closed|pending review" paginate="top" limit="12" author_id="{segment_3}"}
        
            <div class="item2">{product_images}
                <figure>
                    <a href="http://p/{url_title}" title="{title}">_                    {product_images:product_category_resized}</a>{/product_images}
                    </figure>
                    <span class="photo-title"><span  400; font-size: 14px;">{avatar_url} 
                    {screen_name} in {categories limit="1" show="not 1|2|3|4|5"}<a href="http://{path=channel/index}">{category_name}</a>{/categories}</span></span>
             </div>{paginate}
 
  <span>Page {current_page} of {total_pages} pages {pagination_links}</span>
 
 {/paginate}{/exp:channel:entries}
        </div>

As entries are masonry generated, if I put the {exp:channel:entries channel="photos" dynamic="no" order by="random" status="not closed|pending review" paginate="top" limit="12" author_id="{segment_3}”} above <div>NEED AUTHOR NAME HERE</div> author name will be displayed 12 times.

I think I’m doing anything wrong…

Thank you for your help.

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
10 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

It doesn’t have to be outside the tag, just make sure that the author name is only displayed with the first entry returned. Here’s how:

<div id="container-din">
        {exp:channel:entries channel="test" dynamic="no" order by="random" status="not closed|pending review" paginate="top" limit="12" author_id="{segment_3}"}
        {if count == 1}<div>{author}</div>{/if}
            <div class="item2">{product_images}
                <figure>
                    <a href="http://p/{url_title}" title="{title}">_                    {product_images:product_category_resized}</a>{/product_images}
                    </figure>
                    <span class="photo-title"><span  400; font-size: 14px;">{avatar_url} 
                    {screen_name} in {categories limit="1" show="not 1|2|3|4|5"}<a href="http://{path=channel/index}">{category_name}</a>{/categories}</span></span>
             </div>{paginate}
 
  <span>Page {current_page} of {total_pages} pages {pagination_links}</span>
 
 {/paginate}{/exp:channel:entries}
        </div>
       
restos's avatar
restos
54 posts
10 years ago
restos's avatar restos

Thank you

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.