• Resolved philipt18

    (@philipt18)


    I’m creating a page to list posts, and I want the category to be shown, then the title-link to the post, then if there is an author to show it, then the date. I have the following code:

    [loop type=post category=pr,article orderby=date order=DESC paged=10 query=pg]
    [if category=pr]PR[/if]
    [if category=article]Article[/if]
    [field title-link]
    [if field=article-author][field article-author][/if]
    [field date]
    [/loop]
    [loopage query=pg]

    Before I added in the IF statements, the date properly showed up immediately below the title-link. Now wherever there are IF statements there are empty lines. How do I get it to no create the extra space?

    In the code I see the following for each entry:

    PR<br />
    <br />
    <a href="URL">TITLE</a><br />
    <br />
    DATE<br />
    <br />

    In the above example the post was in the PR category, but had no author. Thanks.

    • This topic was modified 4 years ago by philipt18.
Viewing 1 replies (of 1 total)
  • Thread Starter philipt18

    (@philipt18)

    So first I tried enabling the [raw] shortcode and using that, but it didn’t seem to do anything. Not sure if that was to do with Gutenberg or not. Then I changed the code to:

    [loop type=post category=pr,article orderby=date order=DESC paged=10 query=pg][if category=pr]PR[/if][if category=article]Article[/if]
    [field title-link][if field=article-author]<br/>[field article-author][/if]
    [field date]
    <p></p>
    [/loop]
    [loopage query=pg]

    and it seems to work. Basically wherever there was a new line in the code, WordPress was inserting a <br /> tag. Pretty frustrating.

Viewing 1 replies (of 1 total)
  • The topic ‘Extra line spaces in loop where IF statements are’ is closed to new replies.