Viewing 15 replies - 1 through 15 (of 21 total)
  • You can use code to create a shortcode and this code would go into a file called functions.php found in the root folder of your theme, hopefully a child theme.

    Thread Starter Lirael

    (@lirael)

    I don’t know how function I need to write in the function.php of my child theme to display the default text in the short description. That’s why I’ve written this post ??

    Here’s how you can add a shortcode to functions.php.

    Add a Shortcode

    Thread Starter Lirael

    (@lirael)

    ok.. this is probably my fault, sorry for my bad english, I’ll try to explain it in a better way. Forget the shortcode I know how to use it.
    I have installed woocommerce, so I have products.
    In the page where you create products (in the backend, when you click ‘add new product’) there are: the standart editor of wp, the panel with woocommerce options and another editor called ‘short description’.
    In the ‘Short description’ I need to insert a default text inside the editor, so you can see the defaut text and then adding your description.
    Here you can see a screenshot modified with the result: https://i61.tinypic.com/34q4k9l.png

    Thanks and sorry again for bad explanation.

    So in other words, you want that default text to show up automatically in the “Short Description” field whenever you add a product?

    Thread Starter Lirael

    (@lirael)

    yes!

    I don’t think this is possible.

    Thread Starter Lirael

    (@lirael)

    ?? Hmmm… In a teoric line it’s possible, some plugin that adds fields have the impostation to do something like this in their fields.
    I’ve found this for the content editor of standard post: https://www.wpbeginner.com/wp-tutorials/how-to-add-default-content-in-your-wordpress-post-editor/
    But I need to connect it with the woocommerce function, the problem is that I don’t know know how to do it because I dont’ know all the woocommerce functions…

    Well, you could use this code then [in functions.php of your child theme].

    add_filter('woocommerce_short_description', 'my_editor_content', 10, 2);
    
    function my_editor_content( $content ) {
    $content = 'The default text, imposed by me, needs to be here in every product.';
    return $content;
    }
    Thread Starter Lirael

    (@lirael)

    I need to try it from a PC… In the tablet it don’t work, but I’m not at home now, I’ll try it in a few hours.
    Thank you again for your patient help ??

    All right. No problem. ??

    Thread Starter Lirael

    (@lirael)

    Ok, tried also from pc, nothing. Doesn’t work. ??

    1) Are you working with a child theme?
    2) If you can answer ‘yes’ to the question above, did you put it in a file called functions.php?

    Thread Starter Lirael

    (@lirael)

    Yes, in the function.php of my child theme

    You said, “function.php.” It should be functions.php.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘How to add default text in product's short description’ is closed to new replies.