Why use while over if in single wordpress posts?

Why is while() used instead of say if() here: <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( ‘content’, ‘single’ ); ?> <?php _s_post_nav(); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || ‘0’ != get_comments_number() ) : comments_template(); endif; … Read more

Add inline style to get_the_category_list

I need to style the get_the_category_list() a tag but can’t seem to find a way. This is my code: echo ‘<ul class=”list-inline meta-list”>’; // Get the categories $terms = get_the_terms( get_the_ID(), ‘category’); if( !empty($terms) ) { $term = array_pop($terms); $category_color = get_field(‘category_color’, $term ); } $category_list = get_the_category_list( ‘ ‘ ); if ( $category_list ) … Read more

Using previous_post_link and next_post_link to wrap around post sequence

For a single custom post type, I’m using previous_post_link and next_post_link with simple arrows. (Although text arrows are shown here, in the actual I’m using graphics with the text hidden via CSS.) Code: <nav class=”arrowNav”> <div class=”nav-previous”> <?php previous_post_link(‘%link’, ‘«’); ?> </div> <div class=”nav-next”> <?php next_post_link(‘%link’, ‘»’); ?> </div> </nav> This works fine except for … Read more

if is_singular array not working as expected

I’m using the following if statements within header.php to load custom tracking codes. <?php if ( is_singular( array( ‘custom-post-type’, ‘post-name’ ) ) ) : ?> // Specific tracking code here <?php endif ?> <?php if ( is_singular( array( ‘custom-post-type’, ‘another-post’ ) ) ) : ?> // Specific tracking code here <?php endif ?> When I … Read more

Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar

Sorry for any wrong details. I am totally new to WordPress development. I am running a photo site. On single attachment page, I want to show the details (i.e upload date, filename, size, resolution) of the attached image in the sidebar of that single attachment page. I am trying to use the following function in … Read more

How do I create a widget that only allows a single instance?

How do I create a widget that only allows a single instance of a widget to be added through the WordPress interface? The default behaviour of widgets allows multiple instances to be added. I am using the Example code from http://codex.wordpress.org/Widgets_API I have seen a similar question where the answer was to use the old … Read more