Forums

do sticky posts include images? (17 posts)

  1. developdesign
    Member
    Posted 1 year ago #

    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; ?>
  2. jkovis
    Member
    Posted 1 year ago #

    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?

  3. developdesign
    Member
    Posted 1 year ago #

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

  4. developdesign
    Member
    Posted 1 year ago #

    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 )

  5. developdesign
    Member
    Posted 1 year ago #

    Help???

  6. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

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

  7. developdesign
    Member
    Posted 1 year ago #

  8. developdesign
    Member
    Posted 1 year ago #

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

  9. developdesign
    Member
    Posted 1 year ago #

    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:
    http://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 ?

  10. developdesign
    Member
    Posted 1 year ago #

    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(); ?>
  11. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    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.

  12. developdesign
    Member
    Posted 1 year ago #

    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.

  13. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

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

  14. developdesign
    Member
    Posted 1 year ago #

    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: http://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 ): http://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 ): http://greenlightresources.ca/test-home-4/
    Uses specific post code, and just need paragraphs to format.

  15. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Use the_content() and read up on Multiple_Loops.

  16. developdesign
    Member
    Posted 1 year ago #

    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.

  17. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    There's a lot more to it than that. Review the examples given.

Topic Closed

This topic has been closed to new replies.

About this Topic