Change Widget-ID

Hi there,

great theme - thanks!

Is it possible to change the ID of the front-page-widgets? 'Couse for a one page menu the # links (for example #shapely_home_parallax-2) are not optimal and not seo-friendly as well.

Kind regards

Hi @daduda,

I hope you are well today and thank you for your question.

You have to customise it in the “[Shapely] Parralax Section For FrontPage” widget code which is added
in the shapely theme file /shapely/inc/widgets/widget-home-parallax.php

Best Regards,
Movin

Hi Movin,

I’ve opened the file widget-home-parallax.php. I don’t know php well enough to safely make changes, but I’m assuming something has to be changed in this code:

class shapely_home_parallax extends WP_Widget
{
    function __construct(){

        $widget_ops = array('classname' => 'shapely_home_parallax','description' => esc_html__( "Shapely FrontPage Parallax Section" ,'shapely') );
        parent::__construct('shapely_home_parallax', esc_html__('[Shapely] Parralax Section For FrontPage','shapely'), $widget_ops);
    }

Can you tell me what exactly needs to be changed in the code to change the anchor names to something like “#contact” or “#services”?

Thank you.

In the following code you have to change “shapely_home_parallax” to “contact” or “services”.

parent::construct('shapely_home_parallax', esc_html('[Shapely] Parralax Section For FrontPage','shapely'), $widget_ops);

Thanks, Movin. So, whatever I rename “shapely_home_parallax” to will be in the url for all the menu items. In other words, the urls would read “rosslifts.ca/#service-1”, “rosslifts.ca/#service-2”, etc. Is there a way to have the urls read “rosslifts/#about”, “rosslifts.ca/#services”, etc?

Well, that was interesting! I copied the widget-home-parallax.php to my child theme, and changed the code as you suggested; however, nothing happened. So, I directly changed the code in the Shapely folder. It made the site only show the header and the contact widget. All the other widgets disappeared. Any thoughts or suggestions? Thanks, Movin.

Thanks, Movin. So, whatever I rename “shapely_home_parallax” to will be in the url for all the menu items. In other words, the urls would read “rosslifts.ca/#service-1”, “rosslifts.ca/#service-2”, etc. Is there a way to have the urls read “rosslifts/#about”, “rosslifts.ca/#services”, etc?

No because the WordPress adds numbers to the widget ids to distinguish multiple widgets added in the sidebar of same type. It also happens with default WordPress Twenty Sixteen theme.

So, I directly changed the code in the Shapely folder. It made the site only show the header and the contact widget. All the other widgets disappeared. Any thoughts or suggestions?

When you change the ID of widget the WordPress assumes it is new widget so it gets removed from widget area and you have to readd & reconfigure them.

Hi there,
I am having the same issue here but I can’t fix it the way you did because I couldn’t find widgets folder under inc like you said here.

You have to customise it in the “[Shapely] Parralax Section For FrontPage” widget code which is added in the shapely theme file /shapely/inc/widgets/widget-home-parallax.php

I attached what I got under inc folder. So does the place changed or how can I find the folder of widgets to change php?

Best Regards,
Damla

@damlakoksal This is old topic and in the meanwhile the theme is changed a lot so to help us keep support thread separates could you please create your own thread for your question here https://colorlibsupport.com/c/shapely/ instead of replying on others thread as it makes the thread messy and hard to read.

If you want to you can also add reference of this thread in your newly created thread.

We would be more than happy to help you on your new thread.