Portfolio - by designerobot - on WordPress WooCommerce support

This topic has 9 replies, 2 voices, and was last updated 7 years, 3 months ago ago by Laranz

  • Avatar: designerobot
    designerobot
    Participant
    August 4, 2017 at 17:52

    Hello,

    In portfolio section of WooPress, when the categories are too much or when the title is too long, the pagination is not perfect because the grid becomes broken. To maintain the grid still perfect (with all post aligned on the same rows) I need to shorten the two text blocks of text (namely “Project Name” and “ByLine”, as you call them in the theme option).

    I thought it was very simple… I tried these scripts:
    http://www.wpbeginner.com/wp-themes/how-to-truncate-wordpress-post-titles-with-php/
    and
    http://wpsnipp.com/index.php/cat/truncate-description-within-categories-admin-panel/

    But they don’t work on my portfolio page. What is it the right syntax in this case?

    I would like to obatin, jst to example,

    from:
    [PICTURE]
    Category One, Category Two, Catogory three
    Very Long Titles Because Many Many Words

    to:
    [PICTURE]
    Category One, Category…
    Very Long Titles Because…

    with … instead of too many characters

    8 Answers
    Avatar: laranz
    Laranz
    Participant
    August 7, 2017 at 06:25

    Hi,

    1. Use the child theme for code edits.
    2. Copy content-portfolio.php from parent theme to child theme, and edit line #58 from this,

    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

    to

    <h3><a href="<?php the_permalink(); ?>"><?php echo substr(get_the_title(), 0, 55); ?></a></h3>

    or use any other your other techniques you mentioned in the question.

    2. The second snippet for category truncate is for admin screen only, 54th line is for displaying the category, you can customize it in the content-portfolio.php

    Let us know,

    Thanks,
    laranz.

    Avatar: designerobot
    designerobot
    Participant
    August 7, 2017 at 23:39

    Hello Laranz,

    I changed the in the line you said from <?php the_title(); ?> to <?php echo substr(get_the_title(), 0, 55); ?> as you suggested but nothing changes.

    Any other suggestion on how to shorten these two portofolio descriptions?

    Avatar: designerobot
    designerobot
    Participant
    August 8, 2017 at 09:59

    Hello Laranz, sorry I noted that changing the number 55, the code works. But if I add echo "..." it is added to every title (even when it is not cut off).

    Moreover, the problem is that the theme is responsible, therefore there isn’t a “right” number of characters in every situation… do you know if is it possible to set the cutting off according to the line? I.e. making the cutting off just before to start a new line.
    Alternatively to set the right number of characters for every possible width of the page.

    Moreover, how to do the same with the above description with categories?

    Avatar: laranz
    Laranz
    Participant
    August 8, 2017 at 21:48

    Hi,

    In that case you can change like this,

    <?php 
    	$title = get_the_title();
    	if( strlen( $title ) > 55 ){
    		$title = substr( $title, 0, 55 ) . '...';
    	}
    ?>
    <h3><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a></h3>

    Checking the length and then shorten that, if it is shorten then add the. … Theme is not responsible, it gives just a skin, if you want to change you need to customize that in your child theme according to your needs.

    Let us know,

    Thanks,
    laranz.

    Avatar: designerobot
    designerobot
    Participant
    August 9, 2017 at 01:28

    Hi Laranz,

    This works, many thanks.

    I see that there are 5 different skins applied to the Portfolio page, according to the width of the page. The problem is that the above script works in the same way with all different skins, even if in every skin a different number of characters can be shown.
    Could be possible to set a precise number of characters for every width of the page? If this is too complicated please forgotten the answer, I’ll keep the script like it is now that is already a big improvement.

    Avatar: laranz
    Laranz
    Participant
    August 9, 2017 at 03:26

    Hi,

    Yes it is not possible, can’t reduce character according to the widths.

    Let us know if you have any other questions,

    Thanks,
    laranz.,

    Avatar: designerobot
    designerobot
    Participant
    August 9, 2017 at 05:22

    Ok, thank you. I’ll keep it this way 😉

    Avatar: laranz
    Laranz
    Participant
    August 9, 2017 at 05:54

    Hi,

    Glad we helped. 🙂

    Let us know If you have any other questions.

    Thanks,
    laranz.,

  • Viewing 9 results - 1 through 9 (of 9 total)

The issue related to '‘Portfolio’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.