• Resolved spikey_Steve

    (@spikey_steve)


    Using Hueman theme, how do I attach a post to the TOP of the main page? I have tried “sticky” via visibility>sticky — this doesn’t seem to “stick” it to the top of the page!

    This is the page.

    I am trying to get the “Author of the Week” post to stay at the top of the page, with other posts appearing below.

    Thanks in advance.

    Steve

Viewing 10 replies - 1 through 10 (of 10 total)
  • bdbrown

    (@bdbrown)

    Hi spikey_Steve. You might take a look at this thread and see if it helps.

    Thread Starter spikey_Steve

    (@spikey_steve)

    Thanks for your response bdbrown – I appreciate your help.

    I have looked at the thread, and it looks like the post from Alexander Agnarson gives me what I want – kind of!

    I have made a change in the featured.php file – ignore sticky posts has been changed to 0, instead of 1:

    ‘ignore_sticky_posts’ => 0,

    and this has put the sticky exactly where I want it.

    It has, however, kept the original post below it. Can this lower version of the same post be removed, or does it have to stay?

    Here is the page again

    bdbrown

    (@bdbrown)

    Glad you got the sticky post working. You might check Theme Options > BLog > Featured Posts to see if the “Include featured posts…” box is checked. If so, uncheck it and see if that fixes the duplicates.

    Thread Starter spikey_Steve

    (@spikey_steve)

    Hi

    The “include” option is already blank. I checked it and refreshed just incase the setting was a bit iffy, but that didn’t work. I have unchecked it back to default of not selected.

    bdbrown

    (@bdbrown)

    After poking around the theme it appears that the sticky posts query parameter in featured.php is not part of the function that is used to build the list of featured posts to be excluded from the post list.
    Here is the function that builds the list of featured posts that’s used in the exclude posts function:

    function alx_get_featured_post_ids() {
    	$args = array(
    		'category'     => ot_get_option('featured-category'),
    		'numberposts'  => ot_get_option('featured-posts-count')
    	);
    	$posts = get_posts($args);
    	if ( !$posts ) return false;
    	foreach ( $posts as $post )
    		$ids[] = $post->ID;
    	return $ids;
    }

    I’m only guessing that, since the sticky posts parameter is missing, it defaults to 1 (ignore). What you might try is copying that function to your child theme functions.php and adding the sticky posts parameter to see if it will then include them in the featured posts:

    function alx_get_featured_post_ids() {
    	$args = array(
    		'ignore_sticky_posts' => 0,
    		'category'     => ot_get_option('featured-category'),
    		'numberposts'  => ot_get_option('featured-posts-count')
    	);
    	$posts = get_posts($args);
    	if ( !$posts ) return false;
    	foreach ( $posts as $post )
    		$ids[] = $post->ID;
    	return $ids;
    }
    Thread Starter spikey_Steve

    (@spikey_steve)

    Thanks for looking.

    I have tried the code with both options and there is no change either way. I found the following code further up the file – could this have anything to do with it?

    /* Related posts
    /* ———————————— */
    if ( ! function_exists( ‘alx_related_posts’ ) ) {

    function alx_related_posts() {
    wp_reset_postdata();
    global $post;

    // Define shared post arguments
    $args = array(
    ‘no_found_rows’ => true,
    ‘update_post_meta_cache’ => false,
    ‘update_post_term_cache’ => false,
    ‘ignore_sticky_posts’ => 1,

    bdbrown

    (@bdbrown)

    That function is for the related posts displayed below a single post, in the “You May Also Like…” section. OK, here’s another thought, and maybe you’ve already done this, but just thinking out loud here. If the sticky post was in a category, say “sticky”, and the Blog > Featured Category is set to “sticky”, and the Featured Post Count is 1, does that do it?

    Thread Starter spikey_Steve

    (@spikey_steve)

    Hi bdbrown

    I added the category sticky to the list of categories.
    I added the sticky category to the featured post.
    I changed the featured category n the theme options > blog to “sticky”

    Job done!

    The Author of the Week is at the top, as it was intended and it doesn’t show further down the list of posts. The only downside to this method is having the category show as “Author of the Week/Sticky”, but we can live with that!

    I really appreciate your help. I have coded websites in the past, but just using html/css (text editor). I haven’t used WordPress or php at all, so I am learning – fast! – but am a very long way from where I want to be.

    MarionFW

    (@marionfw)

    Why don’t you use another name for the category: for instance “mustread!” instead of sticky? Or any other name you fancy and is better looking?

    bdbrown

    (@bdbrown)

    @marionfw has a good idea; something other than “Sticky” might look better on the featured post. I just threw “sticky” out there as an example. Glad it’s working the way you wanted. Your html/css knowledge will come in handy when working with WP. PHP is a bit of a different animal but not that difficult to learn the basics. And, you can always ask your questions here.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Sticky Post’ is closed to new replies.