• I want my sticky post to include the image from the post, but not sure if that’s a sticky post issue or a coding issue?

    <?php
    $sticky = get_option('sticky_posts');
    rsort( $sticky );
    $sticky = array_slice( $sticky, 0, 1);
    query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
    
    if (have_posts()) : while (have_posts()) : the_post();?>
            <h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <div class="entry">
    <?php the_content(); ?>
    </div>
       <?php endwhile; ?>
    <?php endif; ?>
Viewing 15 replies - 1 through 15 (of 16 total)
  • I want my sticky post to include the image from the post

    — how are you adding the image to the post? From the post editor, featured image, custom field, or something else?

    Thread Starter developdesign

    (@developdesign)

    The image is in the post, so the post editor by adding image from media browser.

    Thread Starter developdesign

    (@developdesign)

    As you can see I’ve also changed from excerpt to content, so thought it would show the entire post ( rather than strip the image )

    Thread Starter developdesign

    (@developdesign)

    Help???

    Images should show as normal in sticky posts when using the_content.

    Thread Starter developdesign

    (@developdesign)

    Thread Starter developdesign

    (@developdesign)

    Why close my other post when I directed you to it??
    Do you want me to post the content in the other post here?

    Thread Starter developdesign

    (@developdesign)

    I’ve looked at the forum rules, so I’m not sure what I did wrong as they aren’t duplicate posts ( although both have to do with sticky posts ).

    So I’m going to post here, since I’ve not been given any feedback on how to post correctly.

    Note: This is the recent news code

    <?php
        query_posts('showposts=1&cat=3'); while(have_posts()) : the_post();?>
    <h2 class="entry-title"><?php the_category(3); ?></h2>
        <h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <div class="entry"><?php the_excerpt(); ?></div>
    <?php endwhile; ?>

    Sticky post code here:
    https://pastebin.com/6WRSeHvU

    IF I use just sticky post then it shows image, but if I use a most recent news post above the sticky post then it strips the image and most of the content??
    Maybe I’m missing a reset query code, so that’s why it’s stripping sticky post or ?

    Thread Starter developdesign

    (@developdesign)

    If I use the following code to pull a specific post after the recent news code, I get the image but the paragraphs aren’t formatted ( no paragraph separation between paragraphs )

    <?php $post_id = 134;
    $queried_post = get_post($post_id); ?>
    <h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <?php echo $queried_post->post_content; ?>

    Note: I’m using ‘get a post” code is at top of page as well. Should I have an closing php tag with this code?

    <?php /*code to display slideshow*/ get_a_post(211); ?>
    <?php the_content(); ?>

    The other topic is still available for people to read but you should not have more than 1 topic open in any given subject at any one time. It causes confusion and results in people wasting their time.

    Thread Starter developdesign

    (@developdesign)

    Well I started with one post on sticky posts, then expanded it to including having multiple posts on one page, so to me they weren’t the same post.

    In either case it’s unfortunate I can’t seem to get any responses on how to solve this coding problem.

    I don’t understand why the sticky post code works fine when above the recent news code then strips images / text when below the recent news code.

    I’ve had the post up a month, so I’d really appreciate help.

    Don’t use <?php echo $queried_post->post_content; ?>.

    Thread Starter developdesign

    (@developdesign)

    Esmi – then what do I use?

    It’s the only solution so far when it actually shows the image in the post, it just doesn’t format the paragraphs.
    Here’s my options so far.

    Here: https://greenlightresources.ca/
    It’s ‘get post’ then ‘sticky post’ and then ‘recent news’ and it all works ( except I want to put ‘recent news’ above ‘sticky post’

    Here ( password: test ): https://greenlightresources.ca/test-home/
    If I use the ‘recent news’ code then the ‘sticky post’ code, then the image and most of the text doesn’t display.

    Here ( password: test ): https://greenlightresources.ca/test-home-4/
    Uses specific post code, and just need paragraphs to format.

    Use the_content() and read up on Multiple_Loops.

    Thread Starter developdesign

    (@developdesign)

    I was looking at the multiple loops code and using <?php endwhile; ?> on first loop and <?php endwhile; ?> <?php endif; ?> on the second loop.
    The sticky post is using the_content() and the recent news is using the_excerpt()

    BUT when I reverse the order of ‘recent posts’ and ‘sticky posts’ code, and switch the positions of the <?php endif; ?> to the bottom of the sticky post code – the image and most text aren’t displayed.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘do sticky posts include images?’ is closed to new replies.