Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with PHP Wordpress Plugin

    Hello,

    This is my first post on the forum and I'm super glad that I found it! hopefully you can help me.

    I am trying to edit a wordpress plugin (https://github.com/samsonw/wp-grid-archives
    ).
    It is an archive plugin that displays post title and excerpt sorted by date. I want to get it to display the post thumbnail or featured image.

    The code is too long to include on this forum but it can be found on github link above. I believe it is in a file called grid-archives.php. I tried various things like placing
    PHP Code:
    <?php the_post_thumbnail$size$attr ); ?>
    But I cant get it to work. I'm pretty useless at PHP unfortunately. Any help would be greatly appreciated. Thanks

    Luke

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    I'm going to take a blind shot at this one, so I don't know if it will work or not.


    First make a safe copy of "grid-archives.php". Always make a copy of any script you modify in case you have to restore it back.

    There are two sections in "grid-archives.php" ... compose_html_classic and compose_html_compact.
    I'm not sure which option you are using.

    Find this part:

    $html .= '<li class="ga_post">'
    . '<div class="ga_post_main">'
    . '<a href="' . get_permalink( $post->ID ) . '" title="' . $post->post_title . '">' . $this->get_excerpt($post->post_title, $this->options['post_title_max_len']) . '</a>'
    . '<p>' . $post->post_content . '</p>'
    . '</div>';

    and change the part in red ....

    $html .= '<li class="ga_post">'
    . '<div class="ga_post_main">'
    . '<a href="' . get_permalink( $post->ID ) . '" title="' . $post->post_title . '">' . $this->get_excerpt($post->post_title, $this->options['post_title_max_len']) . '</a>'
    . '<p>' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</p>'
    . '</div>';

    Change it in either or both 'html_classic' and 'html_compact'

    If it doesn't work, just change it back to the original.
    If it does work, you can then style the display however you want.

    EDIT:
    The parameter 'thumbnail' is directly related to the way you uploaded it into the 'media library'.
    You have the choices 'thumbnail', 'medium', 'large', etc.
    Example: get_the_post_thumbnail($post->ID, 'medium')

    .
    Last edited by mlseim; 02-27-2013 at 08:57 PM.

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for getting back to me! I'll try it in the morning and see if it works

  • #4
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are a legend! I knew it would be something simple.

    Thanks so much.

    Luke


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •