• Resolved gluecklichezwerge

    (@gluecklichezwerge)


    Hello,

    since yesterday I am constantly searching for a solution, but now I give up and ask for help here. Maybe I just got something wrong, because I can’t believe my goal should be that hard to achieve.
    I am looking for a simple, code based solution to expand text on single product pages. I tried using the integrated more-button, expecting a quick and satisfying result, but then it became hours of struggling with search engines (www.remarpro.com included – I am not able to find anything according to my search queries), studying wordpress codex and even more research.
    Do I really need to edit single-product.php to add ‘more’ variable for this?
    To avoid scripts/changes to be overwritten by updates I am using a plugin with which I can add php, js and css to my theme. I do not want to use a child-theme.
    One solution I found requires to create a div class in single-product.php and I would give it a try.

    <div class="collapsed-content">
        <?php
            global $more;
            $temp = $more;
            $more = false;
            $short_description = get_the_content( '' );
            echo $short_description;
            $more = $temp;
        ?></div>

    But due to my requirements I need to add this through functions.php. Any hint on how to achieve that? Or is there a more simple way to add a read more button to product descriptions?
    Please don’t suggest using a plugin. I would like to learn out of this and improve my scripting abilities. ??

    Edit:
    I left the <!–more–> tag in the description as it is not affecting my layout (ID = more-173):
    https://www.gluecklichezwerge.de/produkt/schnullerketten/schnullerkette-mit-namen-glitzerkrone-stern/

    Thank you so much,

    -Bj?rn

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gluecklichezwerge

    (@gluecklichezwerge)

    Update:
    Just ran some tests with inbuild more-tag. Before I deleted my previous changes and then created a new page with pure text and added the more tag between.
    Then I watched the result to toggle between page settings from startpage/frontpage to standard template and at last to full width template (emptied cache before, tried different browsers).
    On none of them the more tag was working. Only thing I see is a line break which I also have in the editor in admin panel when adding the more tag.
    Text Editor:

    View post on imgur.com


    Visual Editor:

    View post on imgur.com

    Any ideas girls or guys? What am I missing?

    To make sure there are no minor issues with my code, I decided to test a small ‘read more’-plugin.
    Surprisingly this is working without any problems. :/

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    As no-one has responded to you on this, I’m going to mark this as resolved to help keep the forums healthy. If you have any further questions, you can start a new thread.

    If you’d like to pursue this further, then I highly recommend contacting one of the services on our customizations page: https://woocommerce.com/customizations/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Read More (More Tag) on Single-Product-Page’ is closed to new replies.