How to add clearfix class according to to the posts number?
Try to update your second code part with $count = 1; foreach( $pages as $post ) { setup_postdata($post); // show your post here if ($count++ % 3 === 0) echo ‘<div class=”clearfix”></div>’;
Try to update your second code part with $count = 1; foreach( $pages as $post ) { setup_postdata($post); // show your post here if ($count++ % 3 === 0) echo ‘<div class=”clearfix”></div>’;
You can’t add arbitrary query variables to the rewrite rules, there’s a whitelist of allowed variables. To add a query variable, use query_vars filter, e.g. this filter adds my-api as a valid query variable: function wpd_query_vars( $query_vars ){ $query_vars[] = ‘my-api’; return $query_vars; } add_filter( ‘query_vars’, ‘wpd_query_vars’ ); But that just gets you the query … Read more
You just need to put your url in the href attribute of the link – like this (I used http://example.com): <?php if( function_exists( ‘the_custom_logo’ ) && has_custom_logo() ) : ?> <figure class=”logo-image”> <?php flash_the_custom_logo(); ?> <?php if( get_theme_mod( ‘flash_transparent_logo’, ”) != ”) : ?> <a href=”http://example.com”> <img class=”transparent-logo” src=”<?php echo esc_url( get_theme_mod( ‘flash_transparent_logo’, ” ) … Read more
This worked for me. I created variables for both the month of the post and the year of the post. <?php $post_month = get_the_time(‘F’); $post_year = get_the_time(‘Y’); if ( is_page(‘about/mission-statement/’)) { echo ‘<time>’ . $post_month . ‘ ‘ . $post_year . ‘:’ . ‘</time>’; } ?>
Dynamic_sidebar pulls whatever widgets are assigned to that sidebar. If you want to add a class for the whole sidebar, surround the call in a div that you can then assign classes. <?php if ( is_active_sidebar( ‘left-sidebar’ ) ) : ?> <div class=”sideclass”> <?php dynamic_sidebar( ‘left-sidebar’ ); ?> </div> <?php endif; ?>
Not really a WordPress related question, but the answer is fairly simple. When you try to call an element of a array that doesn’t exist, you will get an undefined index error, since it simply doesn’t exist. $_GET is a superglobal array, so this is the case. To fix this issue, you should first check … Read more
WordPress has a function that can extract referrer information (website where user originated from): wp_get_referer(). It will return URL from the originating website. If that is not available it will return FALSE. This is the simple example PHP function that will display welcome message when called, if the referrer is set: function wse_280729_show_welcome_message() { $ref … Read more
Have you checked the system status page in WooCommerce to see if there’s anything not functioning properly? Besides that you might want to see if it’s actually a WooCommerce problem, or if for example sendmail() is not working. You can either check it in your PHP settings or by simply requesting a password change for … Read more
Yes. You can get an array of all registered settings via $wp_customize->settings(). If you want to display them all you could do this: if ( is_customize_preview() ) { global $wp_customize; $theme_mods = array(); foreach ( $wp_customize->settings() as $setting ) { if ( ‘theme_mod’ === $setting->type ) { $theme_mods[ $setting->id ] = $setting->value(); } } echo … Read more
First of all edit_user_profile and show_user_profile action hooks don’t have to save the image, you can just add a field there. So function image_up_gall(){ ?> Select image to upload: <input type=”file” name=”fileToUpload” id=”fileToUpload”> <input type=”submit” value=”Upload Image” name=”submit”> <?php } add_action(‘edit_user_profile’, ‘image_up_gall’); add_action(‘show_user_profile’, ‘image_up_gall’); It is because WordPress has its own form tag already, just … Read more