• Hey fellow developers,

    Currently I’m swapping themes. The current one is no longer maintained. The new theme I’m using comes with a nice customizer. I’m not happy with all the settings in the style.css so I made a child-theme. No real sweat. I also want to alter the single.php. No problem but.. I want to use the theme-customizer to change the single.php. So the big question: Is it possible to add new customization items to the child theme and how?

    The main theme has an option to show or hide the featured image on the post. I just need to add “feature only on first page” – otherwise the image shows up on every page of a multi-page post. Dont want that. I can do that in the code my checked if its the first page but want to make it user-friendly.

    The theme is not live a.t.m. – it only lives on a VirtualBox VM at home..

    Any documentation about how the extend the customizer from within a child-theme ?

    Regards
    Sjoerd

    • This topic was modified 4 years, 8 months ago by sjoerd72. Reason: additional info
    • This topic was modified 4 years, 8 months ago by sjoerd72.
    • This topic was modified 4 years, 8 months ago by Jan Dembowski.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • It seems that you don’t really need an option (which is the same to add in a child theme as it is in a parent theme), but simply add a check in the template file.
    My theme does this in archive.php for the description, so it is only output on the first page:

    if ( ! is_paged() ) {
      the_archive_description( '<div class="archive-description">', '</div>' );
    }

    If you want to check an existing theme option, look in the parent theme code to see what the name of the option is. Themes usually use theme_mods, not options, so the call would be something like $classes = get_theme_mod( 'featured_image_classes', $default_featured_image_classes ); and then you use that in an if statement.

    If you want to add a totally new option, I suggest you copy one from the parent theme and change the names. There is PHP and Javascript involved for each option for the Customizer, and then PHP like above to actually use the option.

    Hi there,

    I also want to develop the child theme I recently installed on my wordpress website. I would like to create tables and also divide my content into sections so that the introduction is seen like it is on its own as well as other sub topics of the page.

    The web page where I want to do the customizations on, is this one – https://affiliatedove.com/the-wealthy-affiliate-reviews-ive-tried-it-its-not-a-scam

    Regards,

    Dave

    Moderator bcworkz

    (@bcworkz)

    I agree with Joy that some logic on the template file to conditionally do something makes more sense than a customizer item. That is unless you plan to distribute your theme to others and you want to present user options. If that’s the case work from a generic starter theme, don’t do a child theme. Since you asked, docs on the customizer is available in the Theme Handbook.

    You can create child pages for a particular page if you want to break up content into multiple pages. It’s essentially what the linked handbook does. You can also paginate within a page by inserting page breaks.

    It seems you’ve wandered onto a different topic than that of your OP. FYI, we’d rather you start a new topic instead of having run-on topics covering multiple ideas. It helps to better organize search results when others seek similar help. Doing so also is more likely to bring in other members who might be better qualified to address the new topic. I’m in no way implying Joy is not well qualified in other topics ?? Couldn’t be farther from the truth.

    Thread Starter sjoerd72

    (@sjoerd72)

    @joyously I can manage this in the code. That is not the issue. I got that working too, but I would like to make it more user friendly and place the option in a customizer.
    $featured_image_on_first_page_only is 0 or 1, could be boolean. Not important right now.

    
    if ( ( $featured_image_on_first_page_only == 1 && $page == 1 ) || $featured_image_on_first_page_only == 0 ) {
     // featured image on 1st page or not or show anyways
    }
    

    Also – I was not aware about the is_paged(). Nice to know.

    @bcworkz Thank you for providing the link. I will look into it. I hope it becomes clear. The reason I’m doing a child-theme is that the theme I’m using is a commercial theme and want to extend it without tempering with the original due to updates. Also, I like to learn more about WP.

    Don’t understand you on your last paragraph. I only asked one question which reflects the title.

    Regards
    Sjoerd

    Moderator bcworkz

    (@bcworkz)

    Distributing a child theme to others that is dependent on a commercial theme reduces the number of people who could make use of your hard work. If that’s your preference, there’s nothing wrong with it. It’s common for themes to be developed as children of a common framework theme.

    Creating tables and dividing content sounded much different than adding options to the customizer to me. If you think that is still on topic, that’s fine, no worries.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add options to theme-customizer in child-theme’ is closed to new replies.