WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sticky Posts not working properly (3 posts)

  1. gearhungry
    Member
    Posted 4 months ago #

    Hi guys,

    I recently had a web developer create a new theme template that would enable the setting of sticky posts on the pages of gearhungry.com. For example, the post ID, position, and desired pages would be chosen, and that post would appear on every one of those pages in that given position (say, position 3, on pages 1, 2 and 3, making a static post surrounded by dynamic posts above and underneath).

    The template is currently enabled at this address: http://gearhungry.com/blog

    Unfortunately, while hitting "older posts" at the bottom of the pages changes the URL to page 2, the posts displayed are the exact same as on page 1. Any idea what's wrong with this code?

    Thanks a lot in advance!

    Here is the code:

    <?php
    /*
    Template Name: Sticky Blog Posts
    */
    
    get_header();
    $isPaged = is_paged();
    ($paged = get_query_var('paged')) || ($paged = get_query_var('page')) || $paged = 1;
    $blogfp = true;
    $first = true;
    $lastThumb = '';
    
    if (isset($bf_custom_sticky)) {
    	$bf_sticky_posts = explode(',',$bf_custom_sticky);
    	foreach ($bf_sticky_posts as $bf_sticky_post) {
    		$bf_sticky_par = explode(':', $bf_sticky_post);
    		$bf_sticky_ids[] = $bf_sticky_par[1];
    		if (isset($bf_sticky_par[2])) $bf_sticky_page = $bf_sticky_par[2];
    		$bf_sticky_pos_arr[] = array('pos' => $bf_sticky_par[0], 'id' => $bf_sticky_par[1], 'page' => $bf_sticky_page);
    	}
    
    	$bf_stposts = get_posts( array( 'post__in' => $bf_sticky_ids, 'post_status' => 'any', 'post_type' => 'any' ) );
    	foreach ($bf_stposts as $bf_stpost) $bf_sticky_arr[$bf_stpost->ID] = $bf_stpost;
    }
    $bf_postnum = 1;
    
    if (!$pageTemplate && !$isPaged) blogFrontpageAd();
    
    function bf_show_post() {
    	global $post, $first, $isPaged, $bf_features, $bf_misc, $bf_thumb, $bf_meta, $lastThumb, $bf_normalpost_numwords, $bf_thumbnail_numwords, $bf_postnum;
    	// Get post type
    	if ($first && !$isPaged && in_array('Feature Image', $bf_features) && !in_array('featureFrontpage', $bf_misc)) $postType = "feature";
    	elseif ( (!$first || $isPaged) && in_array('Thumbnails', $bf_thumb)) $postType = "thumb";
    	else $postType = "normal";
    	$postType = apply_filters('bf_post_layout', $postType);
    
    	if ($first) {
    	// if feature image
    	if ($postType == "feature")	bf_featured(); ?>
    
        <?php bf_before_content(); ?>
    	<!-- begin #content -->
    	<div id="content">
    <?php } if(!$first && $postType == "normal") echo '<div class="postdivider"></div>';
    ?>	<!-- begin post -->
    	<div id="post-<?php the_ID(); ?>" class="post frontpage <?php echo $postType;?> <?php echo $lastThumb;?> <?php bigfeature_post_class(); ?>"> <?php
    	if ( $postType == "normal" || $postType == "thumb") {
    		if ($postType !== "thumb" && has_post_thumbnail($post->ID)) {
    			if ($imageurl = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' )) {
    				$image = '<img src="'.$imageurl[0].'" alt="feature post image" />';
    				$image = '<div class="feature-content wp-post-thumbnail"><a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '">'.$image.'</a></div>';
    				if ( in_array('imageBelowTitle', $bf_misc) && $postType !== "thumb") $imageBelowTitle = true;
    				else echo $image;
    			}
    		} else if ($image = get_image($postType, true)) {
    			if ( in_array('imageBelowTitle', $bf_misc) && $postType !== "thumb") $imageBelowTitle = true;
    			else echo '<div class="postimage '.$postType.'">'.$image.'</div>';
    		}
    	}
    
    	if($postType == "thumb") { ?>
    	<div class="thumbcontent"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__ ('Permanent Link to %s', 'BigFeature'), get_the_title())?>" class="thumb-link"><?php the_title(); ?></a></h2> <?php meta($postType); bf_excerpts(false,$bf_thumbnail_numwords,$postType); ?></div>
    
    	<?php } else { ?>
    	<div class="post-title cufonheading"><h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__ ('Permanent Link to %s', 'BigFeature'), get_the_title())?>"><?php the_title(); ?></a></h2><?php if (in_array('Comment Icon', $bf_meta)) { ?><div class="comment"><?php comments_popup_link('0', '1', '%'); ?></div><?php } echo '</div>';  ?>
    
        <?php bf_before_post_content(); ?>
    	<?php if ($imageBelowTitle) echo '<div class="postimage '.$postType.' image-below-title">'.$image.'</div>'; ?>
    	<?php bf_excerpts(false,$bf_normalpost_numwords,$postType); ?>
        <?php bf_after_post_content(); ?>
        <?php bf_below_posts(); ?>
    	<?php } ?>
    
    	</div>
    	<!-- end post -->
    
    	<?php if ($first) { $first = false; if (bf_get_option('bf_cufon')) echo '<script type="text/javascript"> Cufon.refresh(); </script>'; }
    		  if ($postType == "thumb") if ($lastThumb == "last-thumb") { $lastThumb=''; echo '<div class="clear"></div>'; }  else $lastThumb = "last-thumb"; ?>
    
    <?php
    } // end bf_show_post function
    
    $args['ignore_sticky_posts'] = 1;
    $args['post__not_in'] = $bf_sticky_ids;
    query_posts($args);
    if (have_posts()) :
    	while (have_posts()) {
    		the_post();
    		$tmppost = $post;
    		$stickyloop = true;
    		while ( $stickyloop ) {
    			$bf_showpost = null;
    			foreach($bf_sticky_pos_arr as $bf_sticky_pos_post) {
    				if (($bf_sticky_pos_post['pos'] == $bf_postnum)
    				&& (!isset($bf_sticky_pos_post['page']) || (isset($bf_sticky_pos_post['page']) && $paged == $bf_sticky_pos_post['page'])) ) {
    					$bf_showpost = $bf_sticky_pos_post['id'];
    					break;
    				}
    			}
    
    			if (isset($bf_showpost)) {
    				$post = $bf_sticky_arr[$bf_showpost];
    				bf_show_post();
    				$bf_postnum++;
    
    			} else $stickyloop = false;
    		}
    		$post = $tmppost;
    		bf_show_post();
    		$bf_postnum++;
    	}
    ?>
    	<div class="clear"></div>
    	<div class="pagenavigation">
    		<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } elseif (function_exists('wp_page_numbers')) { wp_page_numbers(); } else { ?>
    		<div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries','BigFeature')) ?></div>
    		<div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;','BigFeature')) ?></div>
    		<?php } ?>
    	</div>
    
    <?php else : ?>
    	<div id="content"><p><?php _e('No Posts Found','BigFeature'); ?></p>
    <?php endif; ?>
        <div class="clear"></div>
        </div>
        <!-- end #content -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  2. kmessinger
    Volunteer Moderator
    Posted 4 months ago #

    Since you have a custom theme and then done custom work on it there is no way we can help. Support for your theme is at http://themeforest.net/item/bigfeature-wordpress-theme/51702/support

    http://codex.wordpress.org/Forum_Welcome#Commercial_Products

  3. gearhungry
    Member
    Posted 4 months ago #

    Dang, alright thanks!

Reply

You must log in to post.

About this Topic