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

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

How to hide and content from auto-generated excerpts?

To filter the content only when an auto-excerpt is generated you have to chain the hooks: Hook into get_the_excerpt and register a filter for the_content. In the second filter remove both elements and their content before the excerpt can see it. Sample: add_filter( ‘get_the_excerpt’, ‘t5_excerpt_clean_up’, 1 ); /** * Register handler for auto-generated excerpt. * … Read more

How to programmatically bring back “excerpts” field in post editor in WP 3.1+

http://wordpress.org/support/topic/troubleshooting-wordpress-31-master-list?replies=14 a few posts down has instructions for default ‘ON’ options // Change what’s hidden by default add_filter(‘default_hidden_meta_boxes’, ‘be_hidden_meta_boxes’, 10, 2); function be_hidden_meta_boxes($hidden, $screen) { if ( ‘post’ == $screen->base || ‘page’ == $screen->base ) { // removed ‘postcustom’, $hidden = array( ‘slugdiv’, ‘trackbacksdiv’, ‘postexcerpt’, ‘commentstatusdiv’, ‘commentsdiv’, ‘authordiv’, ‘revisionsdiv’ ); } return $hidden; }

WordPress Errors in generated by theme check plugin [closed]

File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls. The WordPress coding styles require that you make use of the WP Filesystem instead of using direct PHP file functions. You can replace your file_get_contents call easily with: $response = wp_remote_get($feed_url); $file_content = $response[‘body’]; For more specific infos just take a look … Read more

Separated Comment from Post

ahaaa 😀 it’s success, I use CSS. Here the screenshot the code i use on single.php : <!– post section –> <section class=”post-section all-round grid”> <div class=”content_wrapper”> <!– YOUR CONTENT –> </div> </section> <!– end .post-section –> <!– comment section –> <section class=”comment-section all-round grid”> <?php if ( comments_open() || get_comments_number() ) : ?> <?php … Read more

query posts in wordpress

There is no term_id parameter. You need a tax_query. $args = array( ‘post_type’ => ‘my_post’, ‘posts_per_page’ => 6, ‘tax_query’ => array( array( ‘taxonomy’ => ‘yourtaxname’, ‘field’ => ‘id’, ‘terms’ => 1 ) ) ); $query = new WP_Query( $args ); Notice that I’ve use new WP_Query and not query_posts. Don’t use query_posts. Doing the above … Read more