Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thank you for posting this! Saved me a huge headache!

    I was running into the same rub creating a custom widget to integrate into a theme. Defining the widget within functions.php and trying to point to an image file within the widget. The path was correct, however the image was not rendered properly.

    I’m still a relative newb to php, and everything seemed normal in the coding, but the server path to an image wasn’t doing what I wanted. Typing in the absolute uri would work, but of course that wouldn’t be stable across different installations of the theme.

    Thread Starter ashtonfitzgerald

    (@ashtonfitzgerald)

    It turns out that the order of how the php tags are placed affects the outcome dramatically.

    Using my original code, if I place the_permalink before the_excerpt, the permalink points to the proper post. If it’s placed after the_excerpt, it displays the active page permalink.

    This occurs with wp_query as well.

    This is the original get_posts code, but with the ‘watch the dog training video’ link duplicated above the_excerpt. It displays properly above, but not below the_excerpt.

    <?php
     $postslist = get_posts('numberposts=3&orderby=rand&category_name=dog-training-videos');
     foreach ($postslist as $post) :
        setup_postdata($post); ?>
    
    	<em><a href="<?php the_permalink(); ?>">watch the dog training video...</a></em><br /><br />
    
     <div style="border-bottom:1px solid #f0f0f0;">
     <br />
     <strong><?php the_title(); ?></strong>
     <?php the_excerpt(); ?>
    <em><a href="<?php the_permalink(); ?>">watch the dog training video...</a></em><br /><br />
     </div>
     <?php endforeach; ?>

    Can anyone shed some light on this? I don’t mind just permalinking the post title, but now I’m curious how this is working.

    -Ashton

    Thread Starter ashtonfitzgerald

    (@ashtonfitzgerald)

    Thank you. I’m going to try using wp_query() and see how that works out.

    -Ashton

Viewing 3 replies - 1 through 3 (of 3 total)