adding a custom time class to in theme twenty sixteen

Twentysixteen’s header and functions.php appear to support the body_class filter. add_filter(‘body_class’, ‘my_body_classes’); function my_body_classes($classes) { global $wp_query; $time = time() + ( get_option( ‘gmt_offset’ ) * 3600 ); $classes[] = ‘w’ . gmdate( ‘W’, $time ); if ( is_page() && $wp_query->post->post_parent ){ $classes[] = ‘parent-‘ . $wp_query->post->post_parent; } return $classes; }

Changing ‘Add to cart’ button text and relink for some specific products [closed]

Per Ashish’s answer that’s been posted, below is the update code for clarification with the correct answer by switching add_to_cart_url() to get_permalink(): global $product, $post; $hasCustomization = get_post_meta( $post -> ID, ‘_wcm_custom_design_checkbox’, true ); if ( $hasCustomization == ‘on’ ) { echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/237352/%s” rel=”nofollow” data-product_id=”https://wordpress.stackexchange.com/questions/237352/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/237352/%s” class=”add_to_cart %s product_type_%s”>%s</a>’, esc_url( $product … Read more

AJAX save options inside class

Found the issue. First I added ini_set(‘log_errors’,TRUE); ini_set(‘error_reporting’, E_ALL); ini_set(‘error_log’, dirname(__FILE__) . ‘/error_log.txt’); along the define(‘WP_DEBUG’, TRUE); in my wp-config.php, this writes the errors, notices and warnings in the error_log.txt in the root folder (I don’t know why I haven’t thought of that in the first place). Then I saw the errors – I used … Read more

Replace Underscore (_) on Space ( )

You are correct, you need to use str_replace. See details here So the correct code would be: $postData = array( ‘post_title’ => str_replace(‘_’, ‘ ‘, $attachment->post_title), ‘post_type’ => ‘post’, ‘post_content’ => $image_tag, ‘post_category’ => array(‘0’), ‘post_status’ => ‘publish’ );

Custom user roles

To add a role see: https://codex.wordpress.org/Function_Reference/add_role To add capabilities see: click add_cap link on the bottom A list of all caps see: https://codex.wordpress.org/Roles_and_Capabilities For all the roles you can also use them for different post types. if post type is “books” edit_pages -> edit_books. N.B.: This setting is saved to the database (in table wp_options, … Read more

Getting a jQuery library to work in WordPress & Avada

Here’s a tweaked version of the original code. get_template_directory_uri() is used instead of hard coding the URLs, the scripts and styles are enqueud rather than just being registered, and the dependencies are specified. <?php function wptuts_scripts_load_cdn() { wp_enqueue_script( ‘multi-select’, get_template_directory_uri() . ‘/selector/js/jquery.multi-select.js’, array( ‘jquery’ ), null, false ); // JavaScript for theme. Presumably where you’d … Read more