WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Help with some customization. (7 posts)

  1. presdec
    Member
    Posted 2 years ago #

    Here is the website http://ariadneswonderland.gr/

    On the homepage I'm using a drop shadow box plugin
    under the gallery to show a series of images of featured posts, as of right now, as i'm still building the website so it's just lucky luke images inserted from media. What i'd like is to be able to do is have some code that pulls the 5 lastest posts from a category (in this case frontpage id 7) and have their images automatically placed inside the shortcode. Instead of having to retrieve and add links every time i want to change a feature.

    Any ideas/code/snipets/plugins that you might feel would work would be greatly appreciated.

  2. presdec
    Member
    Posted 2 years ago #

    <p style="text-align: center;">[slider_pro id="1"]</p>
    &nbsp;
    &nbsp;
    
    <h1 style="text-align: center;"></h1>
    <h1 style="padding-left: -30px; text-align: left;">Featured Posts.</h1>
    <h1 style="padding-left: 30px; text-align: center;"></h1>
    <p style="padding-left: 30px; text-align: center;">[dropshadowbox align="center" effect="curled" width="97%" border_width="1" border_color="#DDD" inside_shadow="false" ]        <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke.jpg"> <img class="alignnone  wp-image-280" title="lucky-luke" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke-150x150.jpg" alt="" width="135" height="135" /> </a> <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke.jpg"> <img title="lucky-luke" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke-150x150.jpg" alt="" width="135" height="135" /> </a> <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke.jpg"> <img title="lucky-luke" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke-150x150.jpg" alt="" width="135" height="135" /> </a> <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke.jpg"> <img title="lucky-luke" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke-150x150.jpg" alt="" width="135" height="135" /> </a> <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke.jpg"> <img title="lucky-luke" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/lucky-luke-150x150.jpg" alt="" width="135" height="135" /> </a>  [/dropshadowbox]</p>
    [wpcol_1third id="" class="" style=""] <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png"> <img class="alignnone size-full wp-image-300" title="wordpress-250x250" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png" alt="" width="250" height="250" /> </a> [/wpcol_1third] [wpcol_1third id="" class="" style=""] <a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png"> <img title="wordpress-250x250" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png" alt="" width="250" height="250" /> </a>  [/wpcol_1third] [wpcol_1third_end id="" class="" style=""]
    <div class="art-box"><a href="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png"> <img title="wordpress-250x250" src="http://ariadneswonderland.gr/wp-content/uploads/2012/07/wordpress-250x250.png" alt="" width="250" height="250" /> </a></div>
    [/wpcol_1third_end]

    The contents of the Homepage's HTML if it helps.

  3. Max
    Member
    Posted 2 years ago #

    Getting the 5 latest posts is just a custom loop for the one cat. Read The Loop.

    displaying the featured images you need to use WordPress Post Thumnails. The template tag you are looking at is the_post_thumbnail() and Justin Tadlock wrote a pretty comprehensive post on how to use post thumnails in your theme here:

    http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature

  4. presdec
    Member
    Posted 2 years ago #

    Had a look at your link and thank you for the time. With help from walter at webdesigndepot i've now got:
    Still no love tho as i can't figure out how to implement the php into the post, phpexec and similar plugins don't seem to work for this, tho simple things like echo'test'; work fine.

    // fetching latest posts from specific category
    $categoryId = 7;
    $args = array('category' =>  categoryId  , 'post_status' => 'publish', 'numberposts' => 5);
    $posts = get_posts( $args );
    foreach($posts as $post){
      $feat_image_url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
     $post_url = get_permalink($post->ID);
    }
  5. presdec
    Member
    Posted 1 year ago #

    Thanks for the help

    After some struggling, debugging like mad i managed to get a working code:

    $categoryId = 7;
    $args = array('category' =>  $categoryId  , 'post_status' => 'publish', 'numberposts' => 5);
    $posters = get_posts( $args );
    if ( $posters ) {
    foreach ($posters as $post) {  
    
    $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
    ?>
            <a href="<?php echo get_permalink($post->ID); ?>" title=""><img src="<?php echo $imgsrc[0]; ?>" class="thumbnail" width="130" height="130" alt='' /></a> 
    
        <?php }
    }

    I've made it into a shortcode [featuredposts category=7] and calling it lets me add the featured images of the latest 5 posts for a category of my choosing!

  6. presdec
    Member
    Posted 1 year ago #

    Could a moderator please remove the link to the website on the first post.

  7. It is not the general policy to edit or delete forum posts unless they are spam or outright abuse.

    http://codex.wordpress.org/Forum_Welcome#Deleting_.2F_Editing_Posts

    As a matter of policy editing posts like that is not done unless it's an extreme case. That link has been there for 5 months, your case is not extreme.

Topic Closed

This topic has been closed to new replies.

About this Topic