How can I loop into two different DIVS without repeating the DIVs

The key, I think, to what you are doing is to use “offset” <div class=”col4 inner-left”> <ul class=”popular-list”> <?php query_posts(‘order=DESC&posts_per_page=3&post_type=pop’); if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/125200/<?php the_permalink(); ?>”><?php the_title(); ?></a> </li> <?php endwhile; endif; ?> </ul> </div> <div class=”col4 inner-right”> <ul class=”popular-list”> <?php query_posts(‘order=DESC&posts_per_page=3&post_type=pop&offset=3’); if (have_posts()) : while (have_posts()) : … Read more

Get background color for Live Preview with Theme Customization API?

If you’re using the built in custom background stuff, it’s already all using postMessage. So, just bind a function to the background_color message and adjust your border color accordingly. Something like this, I expect: wp.customize(‘background_color’,function( value ) { value.bind(function(to) { jQuery(‘whatever’).css(‘color’, to ? to : ” ); }); }); Obviously, change the jQuery call in … Read more

Understanding WordPress child theme custom JS loading

This is the proper way to load a custom javascript in your child theme, wp_localize_script is only necessary if you need to exchange data between JS and PHP (Client and server). function assets() { wp_register_script(‘ajax_filter’, get_stylesheet_directory_uri() . ‘/js/ajax-filter-posts.js’, [‘jquery’], ‘1.0’, false); wp_enqueue_script(‘ajax_filter’); wp_localize_script( ‘ajax_filter’, ‘mdu’, array( ‘nonce’ => wp_create_nonce( ‘mdu’ ), ‘ajax_url’ => admin_url( ‘admin-ajax.php’ … Read more

List authors with posts in a category

This can become a quite an expensive operation which can seriously damage page load time. At this stage, your code is quite expensive. Lets look a better way to tackle this issue. What we need to do is to minimize the time spend in db, and to do this, we will only get the info … Read more

WordPress Theme customisation CSS

I’ll describe what I did on a project recently that had similar requirements. First thing I did was bundle less.php in my theme and create a function to compile a .less file in my theme into CSS and return the result. It looked like this: function wpse_283711_get_customizer_css() { $css=””; if ( file_exists( get_theme_file_path( ‘customizer.less’ ) … Read more

How to add a text widget during theme activation

You’re almost there, except each widget’s settings are stored separately from the sidebars_widgets option, which just stores widget “instances”. Try out the following function – you’ll still need to use register_sidebar, but it eases the pain for then pre-registering widgets on those sidebars. What it also does is ensure that any existing widgets & their … Read more