Any pointers here at all? One correction – It’s the 404 page I am taken to when I click on one of the Archives.
Thanks.
Hi, you may want to use the_permalink() instead of the_guid()
just checking for typo…. is it archives.php or archive.php?
archive.php is correct in the heirarchy (no s)
does your server have an issue with the php short tags?
<? vs <?php
Hi, you may want to use the_permalink() instead of the_guid()
ah yeah, has the permalink for the post changed at all? I believe the GUID is generated as a unique identifier on the post. The permalink can change, the guid doesn not….. AFAIK (Not done much delving into this)
Hey guys, thanks for the replies.
Regarding the use of the_guid(), I need this as it is actually files that are listed as opposed to posts. This does work, it’s just that ‘http://www.mydomain.com/clientbalances/2010/10/’ is saying that the page is not found.
When I changed ‘archives.php’ to ‘archive.php’ all I get is one link ‘•Archives – 3rd December 2010’ that points back to the archives page.
Oh, no short tags are no issue, server is set to allow them.
Here is my archive.php file –
<?php
/**
* @package WordPress
* @subpackage DD Intranet
* @theme Client Balances
*/
/*
Template Name: Archives
*/
add_filter('getarchives_where', 'getarchives_filter', 10, 2);
function getarchives_filter($where, $args){
$where = "WHERE post_type = 'attachment' AND post_status = 'inherit'";
return $where;
}
get_header();
?>
<div id="pageContainer">
<div id="leftContainer">
<div class="inside">
<div class="section-title"><h2>Historic Client Balances</h2></div>
<ul class="attachments">
<?php wp_get_archives('type=daily&format=custom&before=<li class="arrow">&after=</li>'); ?>
</ul>
</div>
</div>
<div id="rightContainer">
<?php get_sidebar(); ?>
</div>
</div>
<div class="clear"></div>
<?php get_footer(); ?>
Thanks.
Ah, I think I may have found the problem – On the ‘archives.php’ page I use a filter to change the $where variable for the query –
add_filter('getarchives_where', 'getarchives_filter', 10, 2);
function getarchives_filter($where, $args){
$where = "WHERE post_type = 'attachment' AND post_status = 'inherit'";
return $where;
}
But I’ve just printed out the $wp_query for index when a link from the arcive is clicked and it come out as below –
SELECT SQL_CALC_FOUND_ROWS wp_2_posts.* FROM wp_2_posts WHERE 1=1 AND YEAR(wp_2_posts.post_date)='2010' AND MONTH(wp_2_posts.post_date)='12' AND wp_2_posts.post_type = 'post' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private') ORDER BY wp_2_posts.post_date DESC LIMIT 0, 5
I need to somehow change this –
wp_2_posts.post_type = 'post' AND (wp_2_posts.post_status = 'publish' OR wp_2_posts.post_status = 'private')
to this –
wp_2_posts.post_type = 'attachment' AND wp_2_posts.post_status = 'inherit'
Do you know of a filter to do that, as a quick glance in the ‘query.php’ file didn’t yeild an obvious one?
Thanks.
Sorted –
add_filter('posts_where', 'posts_filter', 10, 2);
function posts_filter($where = '', $dates){
global $wp_query;
$year = $wp_query->query_vars['year'];
$month = $wp_query->query_vars['monthnum'];
$where = "AND YEAR(wp_2_posts.post_date)='$year' AND MONTH(wp_2_posts.post_date)='$month' AND post_type = 'attachment' AND post_status = 'inherit'";
return $where;
}
query_posts($query_string);
Thanks for your help guys.