WordPress theme files Organization

It seems like the WordPress community really loves this mix of PHP and HTML together, and as you say it often leads to very hard to understand and maintain code. It is a common programming pattern to separate out ‘logic’ and ‘presentation’. Logic here is PHP code which makes decisions, presentation is HTML. I strongly … Read more

WordPress theme options checkbox default checked state

With the code that you’ve added to your question, you’re adding the HTML ‘checked’ attribute twice, which is probably why things are getting confused. You have it hard-coded as checked=”checked”, but then checked( 1, get_option( ‘theme_custom_option’ ), false ) will write another checked attribute corresponding to the actual value of the option. You should be … Read more

How to dynamically set a background image with the customizer without putting the css as an inline-style

I would recommend changing it to this: <div class=”home-header” style=”background-image:url(‘<?php echo get_theme_mod( ‘home-header-img’ ); ?>’)”> and adding this to style.css or an other stylesheet: .home-header { height: 500px; width: 100%; display: flex; justify-content: center; align-items: center; background-repeat: no-repeat; } In general, inline styles are not allowed, but Themeforest makes an exception for background-images. So by … Read more