1

I am using a Wordpress theme called "business-one-page", here is a link to the demo of the theme: Buisness-One-Page. I am trying to change the structure of the sections. This is a one page theme so what i want to do is re-order the sections and make for example about section display after the service section.

I am using a child theme and have been trying to locate the .php file that has the structure to copy and change into my child theme directory, but can´t find it. Is it possible to do this ?

Thanks in Advance

0

1 Answer 1

1

I'm looking at the free version. The relevant code is in inc/extras.php, and it looks like there are filters to enable / disable sections (business_one_page_ed_<section>_section) and to change the titles of sections (business_one_page_<section>_section_menu_title), but not reorder them:

function business_one_page_get_sections(){
    $sections = array( 'about', 'services', 'cta1', 'portfolio', 'team', 'clients', 'blog',
                       'testimonial', 'cta2', 'contact' );
    $enabled_section = array();
    foreach ( $sections as $section ){
        if ( esc_attr( get_theme_mod( 'business_one_page_ed_' . $section . '_section' ) ) == 1 ){
            $enabled_section[] = array(
                'id' => $section,
                'menu_text' => esc_attr( get_theme_mod( 'business_one_page_' . $section .
                                                        '_section_menu_title','' ) ),
            );
        }
    }
    return $enabled_section;
}

To let you reorder the sections they'd have to filter $sections before processing them or filter $enabled_section before it's returned. Nor is this function pluggable i.e. you can't just overwrite it wholesale (without monkey patching tricks)

So you're going to have to edit the theme, and either

  1. change the order here
  2. add a filter either to the original value of $sections or to $enabled_section so you can edit the order in your filter, and then hook that filter in your child theme

However either will be lost if you update the theme. If you've paid for the theme, or even if you haven't, it might be worth asking Rara Theme if they can add a filter or customisation option here for you for future versions.

2
  • Thank you. If I change the order in the inc/extras.php and copy this to the child theme directory, would it still be lost if I update the theme ?
    – davidhlyns
    Commented Aug 21, 2019 at 11:34
  • I don't think that would work, sorry: I don't think you can just copy the file over and have it use those definitions of the functions instead of the original ones. The original theme will load its copy of business_one_page_get_sections and you can't (easily) just overwrite that with your modified version in PHP. Which is why filters and hooks are useful in core. The alternative approach is the one WordPress uses in pluggable.php, which is to declare its own functions only if you haven't already declared your overridden version first, but this theme isn't set up for that by default either.
    – Rup
    Commented Aug 21, 2019 at 11:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.