0

I'm working on a wordpress site and need to have a widget on the sidebar which has thumbnails, but links to URLs specified per thumbnail rather than the images. It seems simple, but I can't find any plugin to do it in a way a non-developer can from the admin panel.

Currently the NextGEN gallery plugin is being used. Is there any way to configure that, or any similar plugin, in that manner?

How hard would it be to build a plugin from scratch to achieve this, and do you think that's necessary?

0

You could create your own widget that queries posts from a certain category then displays the_post_thumbnail in an unordered list linking to the post.

Example widget (add to functions.php):

<?php

class c3m_thumbnail_posts extends WP_Widget {

function c3m_thumbnail_posts() {
$widget_ops = array( 'classname' => 'thumbnail-posts', 'description' => 'Displays post thumbnails' );
$control_ops = array( 'id_base' => 'c3m-post-thumbnail' );
$this->WP_Widget( 'c3m-post-thumbnail', 'Post Thumbnail Widget', $widget_ops, $control_ops );
}
function widget( $instance ) {
echo $before_widget;
?>
<h2>Title Goes Here</h2>
<?php
    $args = array(
        'cat'       => 16, //Replace with category ID of posts to show thumbnail for
        'posts_per_page' =>  6  //Replace with number of posts to show use -1 for all
    );
    $thumbnail_query = new WP_Query( $args ); ?>

            <ul class="sidebar-thumbnails">
<?php
    while ( $thumbnail_query->have_posts() ) : $thumbnail_query->the_post();  ?>

                <li><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></li>
            <?php endwhile; ?>
            </ul>

<?php
    echo $after_widget;

    }
}

To modify what posts are used see WP_Query class in the codex.

  • Thanks a lot, I'll try working with that. I actually don't know yet how each thing being linked to will be put up, but I would assume this should work. Thanks. – Torneo Jul 30 '11 at 20:57
0

Yes, I have one called Pexeto Portfolio Posts Loader. It displays the image from the URL (or whatever image you like) Not sure if it works on every theme because I got it free and it's designed to work with my theme that creates a custom a Portfolio Category. You could look at the code though or email the developer.

It's likely similar to the above. Did the above code work for you?

Not sure how to get it to you...

Updated: I just looked into it further and it looks like Category Posts Widget may work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.