Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-27-2013, 09:29 AM   PM User | #1
lukeseall
New to the CF scene

 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
lukeseall is an unknown quantity at this point
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
lukeseall is offline   Reply With Quote
Old 02-27-2013, 07:53 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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 07:57 PM..
mlseim is offline   Reply With Quote
Old 02-27-2013, 08:28 PM   PM User | #3
lukeseall
New to the CF scene

 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
lukeseall is an unknown quantity at this point
Thanks for getting back to me! I'll try it in the morning and see if it works
lukeseall is offline   Reply With Quote
Old 02-28-2013, 08:50 AM   PM User | #4
lukeseall
New to the CF scene

 
Join Date: Feb 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
lukeseall is an unknown quantity at this point
You are a legend! I knew it would be something simple.

Thanks so much.

Luke
lukeseall is offline   Reply With Quote
Reply

Bookmarks

Tags
php, thumbnails, wordpress

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:58 AM.


Advertisement
Log in to turn off these ads.