WordPress – show number of comments for each post in widget
Try this <?php echo get_comments_number( $post[‘ID’] ); ?>
Try this <?php echo get_comments_number( $post[‘ID’] ); ?>
If I assign a featured image to any post in question then it does show the correct image. I just don’t understand why every post after the first twelve are using another posts featured image. I think the problem is that you do not reset $image if the current post doesn’t have a featured thumbnail. … Read more
Hope I did get it right: <?php function specialValidation($value) { $explode = explode(‘ ‘, $value); if(sizeof($explode) > 1) { echo ‘ERROR: You have input more than one word.’; return; } $mustBeS = substr($explode[0],0,1); if($mustBeS != ‘s’ && $mustBeS != ‘S’) { echo ‘ERROR: Your word must start with an “s” or “S”.’; return; } }
The typical definition of static page is plain text file, typed by hand or generated by software either. By definition static pages cannot have back-end powered dynamic functionality. There are quite a few approaches to integrating WP (or anything really) with static page, typical being: convert static page to dynamic completely – turn it into … Read more
WordPress Provides a native functions to query these kind of things very easily like WP_User_Query $args = array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => $meta_key1, ‘value’ => $search1, ‘compare’ => ‘LIKE’ ), array( ‘key’ => $meta_key2, ‘value’ => $search2, ‘compare’ => ‘=’ ) ) ); $user_query = new WP_User_Query( $args );
Okay so it works now. The data from the name input is now displayed on front end along with the uploaded image. I honestly can’t explain why… but I basically just copied some lines from the tutorial link I posted and pasted it where it belongs and everything started to work the way it should. … Read more
This cannot work. It has to look like the following (or similar): <?php if (get_post_meta($post->ID, ‘TourURL’, true)) { ?> <div class=”tourenquiryonline”> <h2>Book or Inquire</h2> This tour can be booked online. </div> <?php } elseif (get_post_meta($post->ID, ‘bhid’, true)) { ?> <div class=”tourenquiryonline”> <h2>Book</h2> This tour can be booked online via the form on the right hand … Read more
When you use is_active_sidebar and dynamic_sidebar the argument needs to match the id of a registered sidebar in your theme. In your case that is going to be home_right_1 not sidebar-1 as in the code you copied. Technically, the sidebar name should also work in both and the sidebar index number should work with is_active_sidebar … Read more
For showing category count on your loop – foreach($categories as $category) { echo ‘<li><a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in: %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a> › (‘. $category->count .’)</li>’; } And for showing count with wp_get_archives function, use show_post_count in argument … Read more
Use get_post_field(‘post_content’, $product_page->ID ) to get the content outside loop. <?php $product_pages_args = array( ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => ‘page_library_html.php’ ); $product_pages = get_pages( $product_pages_args ); ?> <?php foreach ( $product_pages as $product_page ) { echo ‘<div id=”posts” class=”flex_100″>’; echo ‘<div id=”library_title”><a href=”‘ . get_permalink( $product_page->ID ) . ‘”>’ . $product_page->post_title . ‘</a></div>’; echo ‘<div … Read more