Home Forums WC Vendors Pro Support $shop_description output limit/truncate characters…

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23124
    Anna
    Member

    Howdy. I am racking my brain trying to limit the characters of the vendor’s shop description output.
    I am using and heavily editing the vendor shop header from the FREE version and using it with PRO.

    I have been able to use css and php to design and output things the way I wish in the headers… with the exception of this feature. I would like to limit/truncate the shop description output in the header, but be able to add a text link to the full shop description.
    The only thing I cannot get to work is limiting the output/characters of text shown from the $shop_description meta. If I don’t limit the characters, then the descriptions could take up half the page if the vendors get wordy.

    I thought I read that you had done this to the PRO vendor shop headers… but so far in looking through the PRO code I have not found it. I was going to use your code and an example and work it into my code for my header.

    If you can help in any way I would be appreciative. Even if it is just to guide me to the pro code if you guys had limited the characters for the shop description in the headers.
    TY
    -Anna

    #23125
    WC Vendors Support
    Participant

    substr.

    http://www.w3schools.com/php/func_string_substr.asp

    echo substr( $shop_description, 100); // for the first 100 characters

    …or to get fancy:

    echo substr( $shop_description, 100) . '...'; // to add some dot dot dots at the end of the string

    #23126
    Anna
    Member

    Voilà! Thanks so much, Ben. I had even visited that site. Unfortunately I did not use the term substr in my searching.
    This will help me get this done.
    Cheers!

    #23127
    WC Vendors Support
    Participant

    You would have found it. I have faith in you. You’re learning REALLY fast.

    What is $shop_description? It’s a variable that contains a string. Ok, that’s great. So, what do we type in google?

    “How do I get the first few characters of a string”

    First link, is the one I showed you. 🙂 Voila! as you say. 😉

    #23131
    Anna
    Member

    *sigh*…. I know. I am SO CLOSE to being done and I have been up without sleep for WAAAY too long. I just wasn’t searching enough or correctly.
    And you’re right- I’ve learned so much. I remember the first request I made for help last summer.. the REALLY LONG email. I can’t believe I wrote that now. All I had to do was try. 🙂 Yay!

    This worked: <?php echo substr( $shop_description, 0,220) . “….”; ?> I had to add the zero so that the excerpt starts at the first character.
    Much better. 😉

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.