• Resolved ronr1999

    (@ronr1999)


    How can I add html code to the text in your widgets? I need a simple unordered list but upon saving all html code is removed.

    I’ve tried a couple of the “Add php to widgets” plugins but that didn’t work.

    Thanks for a great theme!

Viewing 15 replies - 1 through 15 (of 18 total)
  • MariusG

    (@marius_codeinwp)

    Hello Ronr,

    I haven’t tried this myself, but I believe that you could simply add a Text/HTML widget to a section that supports adding widgets. For example in Our Team section, you could still add a HTML widget.

    Let me know if this worked or not.

    Kind regards,
    Marius

    Thread Starter ronr1999

    (@ronr1999)

    Yes, adding another widget does work but then why have your theme? I want your theme to have HTML capabilities.

    Using Our Focus as a sample, I found these changes to the functions.php to work:

    <!– FOCUS HEADING –>
    <?php
    if( !empty($instance[‘text’]) ):
    echo htmlspecialchars_decode(apply_filters(‘widget_title’, $instance[‘text’]));
    endif;

    And…

    function update($new_instance, $old_instance)
    {
    $instance = $old_instance;
    ..
    $instance[‘text’] = wp_filter_post_kses($new_instance[‘text’]);
    ..
    return $instance;
    }

    This works. Also I would like to see that INPUT text field changed to a TEXTAREA. Just makes sense…

    My problem is that I can’t figure out how to get these changes into my child functions.php.

    Thanks ronr1999

    needed to add html to the widget entries in the Our Focus section of Zerif Pro.

    This helped me a lot. Clients don’t want to hear “text only”.

    Thread Starter ronr1999

    (@ronr1999)

    You’re welcome. I had to add this to every section. What a pain! They should really update this theme to include this.

    Hey ronr1999 thanks a lot!!!

    I figure it out how to change the INPUT to a TEXTAREA. In the same file functions.php go to line 868:

    CHANGE

    <input name="<?php echo $this->get_field_name('text'); ?>" type="text" class="widefat" id="<?php echo $this->get_field_id('text'); ?>" value="<?php if( !empty($instance['text']) ): echo $instance['text']; endif; ?>            " />

    TO

    <textarea name="<?php echo $this->get_field_name('text'); ?>" class="widefat" id="<?php echo $this->get_field_id('text'); ?>"><?php if( !empty($instance['text']) ): echo $instance['text']; endif; ?>
                </textarea>

    This should solve your problem!

    Actually I had to change another line at function.php in order to get this working.

    Just search for get_field_name(‘text’) and change the input type to TEXTAREA.

    Thread Starter ronr1999

    (@ronr1999)

    Thanks rafaelponce, I’ll check this out later today.

    Too bad that we have to change to theme’s function.php file. I tried creating a child theme’s function.php with these changes but failed.

    Thread Starter ronr1999

    (@ronr1999)

    I took a look and what rafaelponce has is close but not quite.

    Replace:

    <input type="text" name="<?php echo $this->get_field_name('text'); ?>" id="<?php echo $this->get_field_id('text'); ?>" value="<?php if( !empty($instance['text']) ): echo $instance['text']; endif; ?>" class="widefat"/>

    With:

    <textarea type="text" class="widefat" rows="8" cols="20" value="<?php if( !empty($instance['text']) ): echo htmlspecialchars_decode(apply_filters('widget_title', $instance['text'])); endif; ?>" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php if( !empty($instance['text']) ): echo htmlspecialchars_decode(apply_filters('widget_title', $instance['text'])); endif; ?></textarea>

    Thanks guys! Really helped me out. Annoying that this isn’t a standard feature of this theme.

    I wasn’t able to get this to work with a child theme. Did it work for anyone else? I’m not too concerned right now since the site I’m working on will only be up for a couple of months. It would be good to do it the “right way” for more permanent sites, though.

    Thread Starter ronr1999

    (@ronr1999)

    Glad that this helped. I also couldn’t get it to work with child functions.php. I’m expecting that the theme’s author will fix this before us spending any more time on it! (…hello… anyone listening? )

    Hey maxbe you can help me. Got the same problem. Want to insert html Code in the widget and tried to change the functions.php acording to your advice but it doesn′t work and after the input field in the widget appears the following;

    ” class=”widefat”/>

    what did I do wrong?

    Thread Starter ronr1999

    (@ronr1999)

    You have an error somewhere. Re-read these posts.

    Hi all, I think that I have this working – nothing seems broken so far!
    All of the above pointed me in the right direction. I was trying to make the titles link to the same place as the image link.

    To get it to work in child theme you need to copy the full class into your child theme’s functions.php. (Don’t forget to close the last php tag)
    Follow the steps in this link – https://themegrill.com/support-forum/topic/override-widget-php-in-child-theme/
    and register your new widget eg zerif_child_ourfocus.
    Make the changes to your function as per your additions in earlier posts above and then when you go into Appearance – Widgets your new child widget should be there. When you click it you can add it to whatever section you please.
    Voila. Hope this helps.

    Thanks now it works. ??

    Thanks @ronr1999

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Zerif Widgets – HTML in text?’ is closed to new replies.