• Hi Eliot

    I’m trying to use the new title-link code but when you do something like the following on the loop, it breaks the links and I have to use the old url / title code.

    [loop type="post" count="5"]
        <h4 class="news_box">[content field="title-link" length="62"]</h4>
        <hr class="news_hr" />
        [if every="5"]
            <h4 class="news_box">[content field="title-link" words="4"]</h4>
            <hr class="news_hr" />
        [/if]
    [/loop]

    Also, I think that I might be doing something wrong but with this code, the 5th post title gets duplicated. How do I solve that?

    Thank you

    https://wordpress.org/plugins/custom-content-shortcode/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    Hello,

    Hmm, yes, I see the issue is that the plugin is trying to get 62 characters or 4 words from the title including the link, <a href="...">. I’ll fix that in the next update shortly.

    To avoid duplicating the 5th post title, could you try something like this?

    [loop type="post" count="5"]
        [if not every="5"]
            <h4 class="news_box">[content field="title-link" length="62"]</h4>
            <hr class="news_hr" />
        [/if]
        [if every="5"]
            <h4 class="news_box">[content field="title-link" words="4"]</h4>
            <hr class="news_hr" />
        [/if]
    [/loop]

    I’ll test this tomorrow when I have time, to make sure it works.

    Thread Starter Bernardo Medeiros

    (@bemed)

    Hi,

    I tried to use the code that you posted above but it only returned 2 posts.

    😛

    Cheers

    Plugin Author Eliot Akira

    (@miyarakira)

    Hello, I addressed these two issues in the latest update. Now title-link will be trimmed by word/length before wrapping it in a link. Also [if not every="5"] should work as intended.

    Thread Starter Bernardo Medeiros

    (@bemed)

    Awesome 🙂

    You rock!

    Thread Starter Bernardo Medeiros

    (@bemed)

    I think I broke it again 😛

    [loop type="post" count="5"]
    [if every="1"]
            <p class="news_box"><a href='[content field="url"]'>some random text</a> <span class="news_date"> - [content field="date" date_format="d/m/Y"]</span>
            <hr class="g10-separator-news sep-shadow" />
    [/if]
    [if every="2"]
            <p class="news_box"><a href='[content field="url"]'>some random text 2014</a> <span class="news_date"> - [content field="date" date_format="d/m/Y"]</span>
            <hr class="g10-separator-news sep-shadow" />
    [/if]
    [if every="3"]
            <p class="news_box"><a href='[content field="url"]'>Your Guide to Choosing a CTRM Solutions Provider</a> <span class="news_date"> - [content field="date" date_format="d/m/Y"]</span>
            <hr class="g10-separator-news sep-shadow" />
    [/if]
    [if every="4"]
            <p class="news_box"><a href='[content field="url"]'>You some random text Now</a> <span class="news_date"> - [content field="date" date_format="d/m/Y"]</span>
            <hr class="g10-separator-news sep-shadow" />
    [/if]
    [if every="5"]
            <p class="news_box"><a href='[content field="url"]'>some random text again</a> <span class="news_date"> - [content field="date" date_format="d/m/Y"]</span>
            <hr class="g10-separator-news sep-shadow" />
    [/if]
    [/loop]

    This repeats the 1st if statement after every item of the loop 🙁

    Thanks again

    Plugin Author Eliot Akira

    (@miyarakira)

    Heheh, I see you’re really pushing the limits of the plugin!

    [if every="1"] will display for each post, but you can try [if first]. There’s also [if last].

    For your use case, perhaps there should be a count parameter: [if count="1"]. I’ll make a note of it of a future update.

    Thread Starter Bernardo Medeiros

    (@bemed)

    hehe

    It is not me it is the content editor 😀

    I’ll give it a shot.

    Thank you very much.

    🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Title as a link using a word count or letter count’ is closed to new replies.