Skip Navigation

[Resolved] Loop title issue

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the customer wanted to trim the text that the [wpv-post-title] shortcode provides.

Solution:

In order to do this it will require some custom shortcode.

// Add Shortcode
function trim_link( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'string' => '',
            'length' => '',
            'url' => '',
        ),
        $atts
    );
 
    if (strlen($atts['string']) > $atts['length']){
        $shortened_text = substr($att['string'], 0, $atts['length']);
        return "<a href='".$atts['url']."'>".$shortened_text."...</a>";
    }else{
        return "<a href='".$atts['url']."'>".$atts['string']."</a>";
    }
     
 
}
add_shortcode( 'trim_link', 'trim_link' );

Add it to your functions.php file and then you can add it to your view by doing this.

[trim_link string='[wpv-post-title]' length='140' url='[wpv-post-url]'] 

Please try this and let me know if it helps.
Thanks,

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 44 replies, has 3 voices.

Last updated by Anonymous 6 years ago.

Assisted by: Shane.

Author
Posts
#660495

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

I'm still debugging this and hopefully we arrive at a solution soon.

#663954

Anonymous

Many thanks!

#674125

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

Would you mind if I grabbed a duplicator package from your website for some more advanced debug and testing ?

I wouldnt want the debug information to be showing on your live site.

Please let me know.

Thanks,
Shane

#674148

Anonymous

I don't remember if I send something for this problem but recently I sent to Toolset a duplicator package for sure

#675793

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

So the problem eventually came down to it being an issue with the category its Branca E/G category.

What you can do is to recreate it like I did on the test site and it started working.

Thanks,
Shane

#677329

Anonymous
download.jpg

Hi
I create e new category and assigned the 15 posts to it.
Then I deleted the bugged old category.
Then I set the new one as parent of two others of them.
Then I refreshed and... worse than before! Now 2 posts missing 🙁

#679879

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

Did you remember to change the category to primary on those posts ?

That is strange because this works perfectly in my testing on the duplicator. I must apologize for it not working as intended but could you check on these posts if the primary category has been set.

Thanks,
Shane

#680653

Anonymous

I forgot that step.

Now I set the primary category.

This post
hidden link
with the brand new Branca E/G set as primary is still not showing

hidden link

#692024

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

One last thing that was different when I got this to work in testing was tthat I didnt use the same slug "eg" i used the slug "bg " when I created my new Branca E/G but this time named it Branca E/G 2. This is strange as I see no reason why your original term does not work.

Thanks,
Shane

#692787

Anonymous

Ok 🙂
I wait for further fix

#693242

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

After much checking and debugging i finally found the issue.

<!-- wpv-loop-start -->
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-sm-3"> 
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' ) OR ( '[get_branca_primary_category]' eq 'Branca L/C' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' ) OR ( '[get_branca_primary_category]' eq 'Branca E/G' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' ) OR ( '[get_branca_primary_category]' eq 'Branca R/S' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
		[wpv-item index=other]
			<div class="col-sm-3"> 
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
		[wpv-item index=4]
			<div class="col-sm-3"> 
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-3"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-3"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->

As you can see you are using rows and columns and our [wpv-item index=1] index shortcode. Now the reason why some of the items are missing is because the conditionals in each of the index are not the same.

What you need to do is to add the same conditionals to each of the index except

[wpv-item index=pad]
			<div class="col-sm-3"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-3"></div>

Once you've done this then it should work fine.

Thanks,
Shane

#693841

Anonymous

Ok, well.

Now I add all the conditions to all the indexes but... even 3 posts not showing ?

#694204

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

The Correct solution should be.

<!-- wpv-loop-start -->
    <wpv-loop wrap="4" pad="true">
        [wpv-item index=1]
        <div class="row ">
            <div class="col-sm-3"> 
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' ) OR ( '[get_branca_primary_category]' eq 'Branca L/C' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' ) OR ( '[get_branca_primary_category]' eq 'Branca E/G' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' ) OR ( '[get_branca_primary_category]' eq 'Branca R/S' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
        [wpv-item index=other]
            <div class="col-sm-3"> 
             [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' ) OR ( '[get_branca_primary_category]' eq 'Branca L/C' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' ) OR ( '[get_branca_primary_category]' eq 'Branca E/G' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' ) OR ( '[get_branca_primary_category]' eq 'Branca R/S' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
        [wpv-item index=4]
            <div class="col-sm-3"> 
               [wpv-conditional if="( '[get_branca_primary_category]' eq 'Branco Seeonee' ) OR ( '[get_branca_primary_category]' eq 'Branco Waingunga' ) OR ( '[get_branca_primary_category]' eq 'Branca L/C' )"]
              <div class="notizia-bacheca lc">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Reparto Stella Polare' ) OR ( '[get_branca_primary_category]' eq 'Reparto Campanile Rosso' ) OR ( '[get_branca_primary_category]' eq 'Branca E/G' )"]
              <div class="notizia-bacheca eg">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Noviziato Nuvola Rossa' ) OR ( '[get_branca_primary_category]' eq 'Clan Jonathan Livingston' ) OR ( '[get_branca_primary_category]' eq 'Branca R/S' )"]
              <div class="notizia-bacheca rs">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
              [wpv-conditional if="( '[get_branca_primary_category]' eq 'Comunità Capi' )"]
              <div class="notizia-bacheca capi">[wpv-post-body view_template="Loop item in Notizie"]</div>
              [/wpv-conditional]
          </div>
        </div>
        [wpv-item index=pad]
            <div class="col-sm-3"></div>
        [wpv-item index=pad-last]
            <div class="col-sm-3"></div>
        </div>
    </wpv-loop>
    <!-- wpv-loop-end -->

Thanks,
Shane

#696160

Anonymous
download.jpg

Sorry but with your solution 2 posts are still not showing

Furthermore, there are some errors in closing tags

#700665

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Simone,

It should be working.

Its because in my testing when I created the new category I had assigned some posts to it. I went in and set those back to their original categories, so it should work fine now.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.