• I only want a couple of lines of the descriptions of my services showing on the front page. However as it is right now, the full descriptions of each service are showing. Is there any way to limit the length of the excerpt showing on the front page?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Hi, simplest way is to edit each service and Insert Read More tag as desired.

    Also you can edit theme folder > widgets > fp-services.php and change line:

    $content_html .= '<div class="service-desc wow fadeInUp">' . get_the_content() . '</div>';
    to
    $content_html .= '<div class="service-desc wow fadeInUp">' . get_the_excerpt() . '</div>';

    Thread Starter gmisses

    (@gmisses)

    But then if I edit it so that there’s a read more tag, that will show up on the actual page for services as well and not just the excerpts on the front page?

    For my first reply, yes. If you make changes with get_the_excerpt() excerpt will be shown on front (short text) and when you go to page it will be full text.

    Thread Starter gmisses

    (@gmisses)

    Do I need a child theme for the get_the_excerpt solution to work?

    You don’t need child theme, but It is always good idea to use child theme when modifying theme files since changes will be lost on next theme update.

    Generally it is small change, you can always change it again after the update.

    Thread Starter gmisses

    (@gmisses)

    What if I wanted no text at all to show, so that the services offered would only be listed on the front page but not described…? So that visitors would have to click on the button “See more of our services” to actually see a description. How would I go about doing this?

    Just delete the whole line:
    $content_html .= '<div class="service-desc wow fadeInUp">' . get_the_content() . '</div>';

    And for each Service item you can specify Service link.

    Thread Starter gmisses

    (@gmisses)

    You’re wonderful! Thank you!

    Thread Starter gmisses

    (@gmisses)

    So I created a child theme and created the fp-services.php file. Duplicated the original file from the parent theme and just deleted that one line:
    $content_html .= '<div class="service-desc wow fadeInUp">' . get_the_content() . '</div>';
    It worked lovely in the actual parent theme but it’s not working in the child theme at all… am I missing a step?

    Yeap, you’re missing the fact that widgets don’t get picked up from child themes as they’re not part of the hierarchy. You would need to use unregister_widget and then register your own copy of the widget. Some search results on our forums that might help with this: https://athemes.com/forums/search/unregister_widget/

    Thread Starter gmisses

    (@gmisses)

    This post didn’t help me, can you explain how I go about using unregister_widget in this case pretty please???

    @gmisses
    Here, at the end of this post Vlad explained it very good.

    Thread Starter gmisses

    (@gmisses)

    @dimikjones and @vladff
    I have read through this post: https://athemes.com/forums/search/unregister_widget/ several times. I went to the end and followed these instructions:
    …add to your child theme functions.php file:

    //Unregister the services widget and register it from the child theme
    function moesia_child_widgets() {
    	unregister_widget( 'Moesia_Services' );
    	register_widget( 'Moesia_Products' );
    }
    add_action( 'widgets_init', 'moesia_child_widgets', 99 );
    //Load the new widget
    require get_stylesheet_directory() . "/widgets/fp-products.php";

    Then I created a widgets folder in your child theme, copy fp-services.php in it and change its name to fp-products.php;
    deleted this line: $content_html .= '<div class="service-desc wow fadeInUp">' . get_the_content() . '</div>';
    And lastly went back into my new fp-products.php file and switched the word services to products the first two rows for Moesia_Service Change services to products in both of them.

    Then I get this at the top of my site: //Unregister the services widget and register it from the child theme function moesia_child_widgets() { unregister_widget( ‘Moesia_Services’ ); register_widget( ‘Moesia_Products’ ); } add_action( ‘widgets_init’, ‘moesia_child_widgets’, 99 ); //Load the new widget require get_stylesheet_directory() . “/widgets/fp-products.php”;
    Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at /home/jesgom6/thetipsybrushchicago.com/wp-content/themes/Moesia-CHILD/functions.php:8) in /home/jesgom6/thetipsybrushchicago.com/wp-content/plugins/ninja-forms/ninja-forms.php on line 653

    What did I do wrong?

    This should be correct:
    //Unregister the Product widget and register it from the child theme
    function moesia_child_widgets() {
    unregister_widget( ‘Moesia_Products’ );
    register_widget( ‘Moesia_Products_New’ );
    }
    add_action( ‘widgets_init’, ‘moesia_child_widgets’, 99 );
    //Load the new widget
    require get_stylesheet_directory() . “/widgets/fp-products-new.php”;

    You are unregistering Services and registering Products and change fp-products.php to fp-products-new.ph in your child theme. Also you must set this to all other frontpage widgets.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Services excerpts on front page’ is closed to new replies.