Help with code for a slider module in a wordpress theme
Moderator: General Moderators
-
symbolscape
- Forum Newbie
- Posts: 5
- Joined: Tue Jul 20, 2010 8:46 pm
Help with code for a slider module in a wordpress theme
hey folks,
I'm a web video producer working on my first website development project. I have run across a bit of a problem with the theme I purchased from Woo Themes:
http://www.woothemes.com/demo/?name=the-journal
At the section on the lower third of the content titled "Also in this site..." they have a slider that calls up the most recent posts. I would like the slider items to point to pages instead of posts.
Can anyone point me in the right direction on how to understand what's happening there?
I'm a web video producer working on my first website development project. I have run across a bit of a problem with the theme I purchased from Woo Themes:
http://www.woothemes.com/demo/?name=the-journal
At the section on the lower third of the content titled "Also in this site..." they have a slider that calls up the most recent posts. I would like the slider items to point to pages instead of posts.
Can anyone point me in the right direction on how to understand what's happening there?
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Help with code for a slider module in a wordpress theme
The wp_list_pages() function generates a list of pages rather like you can see at the bottom of the page you linked to - open up the footer.php file to take a peak at this in action.
But if, for example, you want to dynamically list each page title along with a short extract and maybe a thumbnail of the first image (so it looks like the existing template), then I imagine you will need to create your own loop using the wp_query class.
But if, for example, you want to dynamically list each page title along with a short extract and maybe a thumbnail of the first image (so it looks like the existing template), then I imagine you will need to create your own loop using the wp_query class.
-
symbolscape
- Forum Newbie
- Posts: 5
- Joined: Tue Jul 20, 2010 8:46 pm
Re: Help with code for a slider module in a wordpress theme
Thanks for your reply, Greyhound. I looked at the footer.php and have a sense for what's happening there, but the slider seems different. Obviously, I'm a noob and I'm probably not picking up on something evident. As far as I can tell, this is the code for the slider. This was taken out of the index.php. What exactly is the code saying here? Is there a simple tweak I can make here to replace the section calling for posts and insert a wp_list_pages() instead?
Code: Select all
<!-- CATEGORIES MODULE STARTS -->
<div id="categories-module">
<?php
$counter = 1;
$image_height = get_option('woo_featured_sidebar_image_dimentions_height');
$featured_limit = 3;
$featured_limit = get_settings('woo_featured_tag_amount');
$new_posts = get_posts("tag=$featured_tag&showposts=$featured_limit&offset=1");
foreach($new_posts as $post){
setup_postdata($post);
$counter++; ?>
<div class="category-box">
<p class="category"><?php the_category(', ') ?></p>
<div class="category-image-block"><?php woo_get_image('image','134',$image_height); ?></div>
<h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
<div class="fix"></div>
</div>
<?php
}
?>
<?php if(!empty($featured_tag)){
global $wpdb;
$result = $wpdb->get_var("SELECT term_id FROM $wpdb->terms WHERE name = '$featured_tag'");
$term_id = (int)$result;
?>
<p><?php _e('Go to the', 'woothemes'); ?> <a href="<?php echo get_tag_link($term_id); ?>"><?php _e('Archives', 'woothemes'); ?></a> <?php _e('to see more entries', 'woothemes'); ?></p>
<?php } ?>
</div> <!-- CATEGORIES MODULE ENDS -->
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Help with code for a slider module in a wordpress theme
One possibility is replacing the get_posts() function with get_pages(), however keep in mind that a straight swap is not possible as categories, tags etc are not supported by pages (unless this is one of the changes introduced by v3) and so you would also have to change the function parameters.
Following on from that, currently the category name is displayed - you would likely have to remove this or replace it with something page oriented - again this is because pages in Wordpress do not belong to categories (and, again, if this has changed with the advent of v3 and its taxonomies feature then I stand corrected).
Last and by no means least, the code you posted features a number of custom functions: these might continue to work as expected but I wouldn't bet the house on it, so you may have to edit these or create new ones (in case other parts of the theme also rely on the current set of custom functions).
Reading over what I just wrote, I think the cleanest and easiest approach would actually be to build some new custom functions that do exactly what you want, then update the index.php/home.php file appropriately...
Obviously you would need to build (or have someone build on your behalf) the relevant custom functions to do the 'heavy lifting' there, so to speak.
Following on from that, currently the category name is displayed - you would likely have to remove this or replace it with something page oriented - again this is because pages in Wordpress do not belong to categories (and, again, if this has changed with the advent of v3 and its taxonomies feature then I stand corrected).
Last and by no means least, the code you posted features a number of custom functions: these might continue to work as expected but I wouldn't bet the house on it, so you may have to edit these or create new ones (in case other parts of the theme also rely on the current set of custom functions).
Reading over what I just wrote, I think the cleanest and easiest approach would actually be to build some new custom functions that do exactly what you want, then update the index.php/home.php file appropriately...
Code: Select all
// Prepare to list a total of 5 pages where the frontpage custom field exists
$pages = greyhound_CustomPages(5, "frontpage");
// Loop through
foreach ($pages as $page)
{
?>
<div class="page_listing">
<h4><?php echo $page['title']; ?></h4>
<img src="<?php echo $page['thumbnail']; ?>" />
<p><?php echo $page['blurb']; ?></p>
</div>
<?php
}
?>-
symbolscape
- Forum Newbie
- Posts: 5
- Joined: Tue Jul 20, 2010 8:46 pm
Re: Help with code for a slider module in a wordpress theme
Greyhound, thanks again for your reply and code. Frankly, I'm cynical that I will be able to figure this out in any short period of time, but I'm going to give it a shot.
Another theme that has a similar functionality is made by GraphPaperPress. Their slider looks like this:
http://demo.graphpaperpress.com/modularity/
What I like about their slider is that it has a handle that makes navigating through the thumbnails a bit more user friendly. I will have several hundred pages to navigate through, so the arrow navigation on the Woo themes slider would probably not suffice.
Out of curiosity, how much would it cost to contract a project like this out? What's a fair rate?
Another theme that has a similar functionality is made by GraphPaperPress. Their slider looks like this:
http://demo.graphpaperpress.com/modularity/
What I like about their slider is that it has a handle that makes navigating through the thumbnails a bit more user friendly. I will have several hundred pages to navigate through, so the arrow navigation on the Woo themes slider would probably not suffice.
Out of curiosity, how much would it cost to contract a project like this out? What's a fair rate?
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Help with code for a slider module in a wordpress theme
You'll find rates vary hugely, but some back-of-a-cigarette-packet calculations suggest £100-200 as a final cost (I'm in the UK). That may seem disproportionate to the price of the theme itself but then that's the difference between off-the-shelf and custom built.
Even so it isn't a massive job and if you persevere you will probably get there yourself with a little help from forums like this (and of course the WP forums).
If you go down the route of trying it yourself then what I would suggest (if this is teaching you to suck eggs then please ignore me!) is that first of all you figure out the PHP code to extract page titles, page summaries and thumbnails (or whatever bits and bobs you want to use as teasers for each page), and at least initially forget about the appearance.
Once you are retrieving the correct items, then think about styling it and implementing your "slider" control (or whatever you want to call it). You might surprise yourself with how easy this can be thanks to a bit of CSS plus JQuery and some of the fantastic plugins that are out there.
Even so it isn't a massive job and if you persevere you will probably get there yourself with a little help from forums like this (and of course the WP forums).
If you go down the route of trying it yourself then what I would suggest (if this is teaching you to suck eggs then please ignore me!) is that first of all you figure out the PHP code to extract page titles, page summaries and thumbnails (or whatever bits and bobs you want to use as teasers for each page), and at least initially forget about the appearance.
Once you are retrieving the correct items, then think about styling it and implementing your "slider" control (or whatever you want to call it). You might surprise yourself with how easy this can be thanks to a bit of CSS plus JQuery and some of the fantastic plugins that are out there.
-
symbolscape
- Forum Newbie
- Posts: 5
- Joined: Tue Jul 20, 2010 8:46 pm
Re: Help with code for a slider module in a wordpress theme
Greyhound, thanks so much for your advice and direction here. I will indeed dive into the code and see what I can come up with. I may end up subcontracting in the end, but I think it's worth it to see what I can teach myself. And let me say that I can only muster that spirit with the firm faith that there are helpful people in the world, an idea born and bolstered in your efforts to help me out here. For that, I am grateful for not only your relevant advice to the code problem, but more so for your reaffirmation of my faith in human kindness, striking as it is in a world that too often seems to be a present a waning sense that there are good people living on our planet. That is my long winded and round about way of saying thanks again a thousand times for your help.
Cheers.
Cheers.
- greyhoundcode
- Forum Regular
- Posts: 613
- Joined: Mon Feb 11, 2008 4:22 am
Re: Help with code for a slider module in a wordpress theme
No problem, post back or start a new thread as appropriate if you need more help.
It should be a great way for you to become acquainted with WP "under the hood".
It should be a great way for you to become acquainted with WP "under the hood".