here, let me just make this easier and post the whole code:
I am using a template that posts all the images in one gallery, ordering them by year. As I said before, I want to put make multiple galleries, putting images in separate pages, seperated by what category was.
This is the original code for the template:
if (have_posts()) : while (have_posts()) : the_post();
?>
<div id="pagecontent">
<h2><?the_title();?></h2>
<?the_content('');?>
<?php
$posts = get_posts('numberposts=-1&order=DESC');
$postyear = 0;
foreach ($posts as $post) {
$this_postyear = intval(substr($post->post_date, 0, 4));
if ($this_postyear != $postyear) {
$postyear = $this_postyear;
echo '<h2 class="mosaicheader">'.$postyear.'</h2>';
}
$image = YapbImage::getInstanceFromDb($post->ID);
if ($image->width > $image->height) {
$thumb_param = array(
'sx='.intval(($image->width - $image->height)/2),
'sy=0',
'sw='.$image->height,
'sh='.$image->height
);
} elseif ($image->width < $image->height) {
$thumb_param = array(
'sx=0',
'sy='.intval(($image->height - $image->width)/2),
'sw='.$image->width,
'sh='.$image->width
);
} else {
$thumb_param = array();
}
array_push($thumb_param, 'h=100', 'q=70');
echo '<a href="'.get_permalink($post->ID).'">';
echo '<img class="mosaic" src="'.$image->getThumbnailHref($thumb_param).'" />';
echo '</a>';
}
?>
Now I get rid of the code that separates and order it by date, but because I don’t want that and add your code and I get:
if (have_posts()) : while (have_posts()) : the_post();
?>
<div id="pagecontent">
<h2><?the_title();?></h2>
<?the_content('');?>
<?php
$page-title = get_the_title();
$myposts = new WP_Query('category_name='.$page-title);
while($myposts->has_posts()) { $myposts->the_post();
... do all the normal loop here ...
}
foreach ($posts as $post) {
$image = YapbImage::getInstanceFromDb($post->ID);
if ($image->width > $image->height) {
$thumb_param = array(
'sx='.intval(($image->width - $image->height)/2),
'sy=0',
'sw='.$image->height,
'sh='.$image->height
);
} elseif ($image->width < $image->height) {
$thumb_param = array(
'sx=0',
'sy='.intval(($image->height - $image->width)/2),
'sw='.$image->width,
'sh='.$image->width
);
} else {
$thumb_param = array();
}
array_push($thumb_param, 'h=100', 'q=70');
echo '<a href="'.get_permalink($post->ID).'">';
echo '<img class="mosaic" src="'.$image->getThumbnailHref($thumb_param).'" />';
echo '</a>';
}
?>
If I am screwing this up somewhere, and I can assure you I am as I am very new to php/wordpress, please let me know. Not only do I want to be able to get this to work, but I want to learn. Sometimes it all seems to overwhelm me though.