Tag Archives: wordpress
I also had a few questions about Wordpress that we didn’t have time to answer in today’s class.
- We touched on it in Class a bit with Karen’s site but never came to a solution. Currently i have the Navigation in the white strip inside header.php. No matter what page you visit this looks the same. I was hoping to have the section you were currently on be highlighted. That part seems fairly simple but in addition to changing the look of the section title i was hoping to have a accordion type effect where for example the WORK section would extend to show a submenu, consisting of 3 or 4 links. I know i can achieve this through taking the navigation out of the header.php and including it individually on each page template. I’m pretty sure there is a much more “elegant” way of doing this that i am missing.
- In the BLOG section when you are in a “single page” you have the option to click “next post” and “prev post” and they are working as i would like. Since I am using the query_post fuction to hide all of the posts that are filed under the category “portfolio”, the next and prev buttons still find those “portfolio” posts (which dont even follow the same “single” template, which causes you to leave the blog unexpectedly).
I have searched around briefly but thought i would post to see if someone knew the answers to these questions before i spent hours looking for solutions. I’m almost there!
Thanks,
Here’s a Wordpress code snippets I thought you might find useful. It is a functions you can dump in functions.php and then use in your theme. This one would get you the first image from any post you pass it. This is a great way for you guys to get thumbnails for your posts without extra effort. Here we go:
Snippet
Paste this code into anywhere in your functions.php file
function get_first_image($post_ID, $fullsize=false, $max_dims=false){ $thumbargs = array( 'post_type' => 'attachment', 'post_status' => null, 'post_parent' => $post_ID ); $thumbs = get_posts($thumbargs); if ($thumbs) { $num = count($thumbs)-1; return get_attachment_innerHTML($thumbs[$num]->ID, $fullsize, $max_dims); } }
Parameters
This function expects to be passed three parameters: $post_ID The ID of the post you want the first image for (you can get it easily from the loop for example) $fullsize Are you trying to refer to the full size image? [true] or to the thumbnail [false]. Default: false $max_dims Do you want to make the image resize proportionally? If so, pass a single number [300] to limit it equally on both height and width or pass an array of two values, width and height [array(300,200)] to have different height and width size limits. If you don’t want to limit size pass false. [false] Default: false
Returns
This function would return the img tag with the alt tag, image resizing and all. So putting this in your theme:
get_first_image (35, true, array(300, 350));
Might return this:
<img title="my image title" src="http://artfocus.org.il/en/wp-content/uploads/2008/08/durham-jd_coll-stones_brasilian2.jpg" alt="my image description" width="300" />In this case http://artfocus.org.il/en/wp-content/uploads/2008/08/durham-jd_coll-stones_brasilian2.jpg is the full sized image, and being of landscape proportions it is being its size is being resized to proportionally fit the 300px width. If it would have been a vertical image, it might have resized by the 350px height and then its width might resize to less than 300px. Enjoy.
Thanks
Thanks to Crerem and Ben Colman, for providing bug report and patches to the code (thrugh the comments)
Indexhibit:
- Write a CSS Plugin for Indexhibit, please communicate with the rest of us what your plugin will be about.
- Chip in on the documentation for the Sandbox theme
- Let’s communicate about our Friday gig.
Wordpress:
- Start diving into plugins.
- Make your theme links url independent.
- Upload content to your blog.
- Get ready to finish this thing.
Enjoy
As our process becomes more self-directed, I do not have any specifics for you for next week but:
- Continue down the WP path:
- try to finish the main page
- Next go to post page (single.php) (+ if relevant: comments.php)
- Then to page page (page.php)
- Then to the menus (archive.php archives.php author.php category.php tag.ph)
- Then to search (search.php)
- Last (/optional): 404.php, attachment.php, image.php, links.php)
- Let’s get our heads into Indexhibit and how can we make it better:
- We’ll discuss it in class today
- Let’s share some findings from the Indexhibit forum that can shed some light on where to take this
- Let’s experiment with theming Indexhibit, it’s not hard, how can it be easier?
- Leonie will be back next week with a ‘Great Wide Open’ for us.
- Enjoy

