Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Modify my theme WordPress

  • SOLVED

Hi,
I am using a new theme on http://www.mobilequity.de/. However, when displaying the category page, e.g. http://www.mobilequity.de/?cat=13 I would like to get the first, or the two first or any other adjustable number of the attached images of a page displayed. An example of a page with attached images is http://www.mobilequity.de/?page_id=872 .

The code of the category.php is:

<?php
/**
* The main template file for display category page.
*
* @package WordPress
*/

/**
* Get Current page object
**/
$page = get_page($post->ID);

/**
* Get current page id
**/

if(!isset($current_page_id) && isset($page->ID))
{
$current_page_id = $page->ID;
}

get_header();

//Get Page background style
$pp_blog_bg = get_option('pp_blog_bg');

if(empty($pp_blog_bg))
{
$pp_blog_bg = '/example/bg.jpg';
}
?>
<script type="text/javascript">
jQuery.backstretch( "<?php echo $pp_blog_bg; ?>", {speed: 'slow'} );
</script>

<!-- Begin content -->
<?php
//Get social media sharing option
$pp_social_sharing = get_option('pp_social_sharing');

if(!empty($pp_social_sharing))
{
?>
<div class="gallery_social">
<div class="each">
<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&amp;href=<?php echo urlencode($page->guid); ?>&amp;send=false&amp;layout=box_count&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>
</div>
<div class="each">
<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<div class="each">
<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>

<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
</div>
<?php
}
?>

<div class="page_control">
<a id="page_minimize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>
</a>
<a id="page_maximize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>
</a>
</div>

<div id="page_content_wrapper">
<div class="inner">
<!-- Begin main content -->
<div class="inner_wrapper">
<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">
<h1 class="cufon"><?php printf( __( ' %s', '' ), '' . single_cat_title( '', false ) . '' ); ?></h1>
</div>
<div class="sidebar_content">

<?php

global $more; $more = false; # some wordpress wtf logic

if (have_posts()) : while (have_posts()) : the_post();

$image_thumb = '';

if(has_post_thumbnail(get_the_ID(), 'large'))
{
$image_id = get_post_thumbnail_id(get_the_ID());
$image_thumb = wp_get_attachment_image_src($image_id, 'large', true);


$pp_blog_image_width = 600;
$pp_blog_image_height = 260;
}
?>

<!-- Begin each blog post -->
<div class="post_wrapper">

<?php
if(!empty($image_thumb))
{
$small_image_url = wp_get_attachment_image_src($image_id, 'blog', true);
?>

<br class="clear"/>
<div class="post_img">
<a href="<?php echo $image_thumb[0]; ?>" class="img_frame">
<img src="<?php echo $small_image_url[0]; ?>" alt="" class=""/>
</a>
</div>

<?php
}
?>

<br/>
<div class="post_date">
<div class="month"><?php the_time('M'); ?></div>
<div class="date"><?php the_time('j'); ?></div>
<div class="year"><?php the_time('Y'); ?></div>
</div>

<div class="post_header">
<h5 class="cufon"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
<div class="post_detail">
<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?> on <?php echo get_the_time('d M Y'); ?> /
<a href=""><?php comments_number('0 Comment', '1 Comment', '% Comments'); ?></a>
</div>
</div>
<br class="clear"/>

<?php
$pp_blog_display_full = get_option('pp_blog_display_full');

if(!empty($pp_blog_display_full))
{
the_content();
}
else
{
the_excerpt();
?>

<br/><br/>
<a href="<?php the_permalink(); ?>"><?php echo _e( 'zum Angebot...', THEMEDOMAIN ); ?></a>

<?php
}
?>

</div>

<!-- End each blog post -->
<?php endwhile; endif; ?>

<div class="pagination"><p><?php posts_nav_link(' '); ?></p></div>

</div>

<div class="sidebar_wrapper">

<div class="sidebar_top"></div>

<div class="sidebar">

<div class="content">

<ul class="sidebar_widget">
<?php dynamic_sidebar('Category Sidebar'); ?>
</ul>

</div>

</div>
<br class="clear"/>

<div class="sidebar_bottom"></div>
</div>

</div>
<!-- End main content -->

</div>
</div>
<br class="clear"/>
<?php get_footer(); ?>



and the template for the gallery that is attached to the page is comrpising the following code:

<?php
/**
* The main template file for display portfolio page.
*
* Template Name: Gallery 4 Columns
* @package WordPress
*/

/**
* Get all photos
**/

$menu_sets_query = '';

$portfolio_items = -1;

/**
* Get Current page object
**/
$page = get_page($post->ID);
$current_page_id = '';

if(isset($page->ID))
{
$current_page_id = $page->ID;
}
$page_style = 'Right Sidebar';
$page_sidebar = get_post_meta($current_page_id, 'page_sidebar', true);

if(empty($page_sidebar))
{
$page_sidebar = 'Page Sidebar';
}

$add_sidebar = FALSE;
if($page_style == 'Right Sidebar')
{
$add_sidebar = TRUE;
$page_class = 'sidebar_content';
}
else
{
$page_class = "full_width";
}
get_header();
//Check if password protected
$portfolio_password = get_post_meta($current_page_id, 'portfolio_password', true);
if(!empty($portfolio_password))
{
session_start();

if(!isset($_SESSION['gallery_page_'.$current_page_id]) OR empty($_SESSION['gallery_page_'.$current_page_id]))
{
include (get_template_directory() . "/templates/template-password.php");
exit;
}
}

//Get content gallery
$gallery_id = get_post_meta($current_page_id, 'page_gallery_id', true);

$args = array(
'post_type' => 'attachment',
'numberposts' => $portfolio_items,
'post_status' => null,
'post_parent' => $gallery_id,
'order' => 'ASC',
'orderby' => 'menu_order',
);

//Get gallery images
$all_photo_arr = get_posts( $args );

get_header();

//Get Page background style
$bg_style = get_post_meta($current_page_id, 'page_bg_style', true);

//Check browser and version for performance tuning
$isIE8 = ereg('MSIE 8',$_SERVER['HTTP_USER_AGENT']);
if($isIE8)
{
$bg_style = 'Static Image';
}

if($bg_style == 'Static Image')
{
if(has_post_thumbnail($current_page_id, 'full'))
{
$image_id = get_post_thumbnail_id($current_page_id);
$image_thumb = wp_get_attachment_image_src($image_id, 'full', true);
$pp_page_bg = $image_thumb[0];
}
else
{
$pp_page_bg = get_stylesheet_directory_uri().'/example/bg.jpg';
}
?>
<script type="text/javascript">
jQuery.backstretch( "<?php echo $pp_page_bg; ?>", {speed: 'slow'} );
</script>

<?php
} // end if static image
else
{
$page_bg_gallery_id = get_post_meta($current_page_id, 'page_bg_gallery_id', true);
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $page_bg_gallery_id,
'order' => 'ASC',
'orderby' => 'menu_order',
);
$bg_photo_arr = get_posts( $args );
?>

<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/supersized.css" type="text/css" media="screen" />

<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/supersized.3.1.3.js"></script>
<script type="text/javascript" src="<?php echo get_stylesheet_directory_uri(); ?>/js/supersized.shutter.js"></script>

<script type="text/javascript">

jQuery(function($){
$.supersized({

//Functionality
slideshow : 1, //Slideshow on/off
autoplay : 1, //Slideshow starts playing automatically
start_slide : 1, //Start slide (0 is random)
random : 0, //Randomize slide order (Ignores start slide)
slide_interval : 10000, //Length between transitions
<?php
$pp_homepage_slideshow_trans = get_option('pp_homepage_slideshow_trans');

if(empty($pp_homepage_slideshow_trans))
{
$pp_homepage_slideshow_trans = 1;
}
?>
transition : <?php echo $pp_homepage_slideshow_trans; ?>, //0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed : 500, //Speed of transition
new_window : 1, //Image links open in new window/tab
pause_hover : 0, //Pause slideshow on hover
keyboard_nav : 1, //Keyboard navigation on/off
performance : 1, //0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
image_protect : 0, //Disables image dragging and right click with Javascript

//Size & Position
min_width : 0, //Min width allowed (in pixels)
min_height : 0, //Min height allowed (in pixels)
vertical_center : 1, //Vertically center background
horizontal_center : 1, //Horizontally center background
<?php
$pp_enable_fit_image = get_option('pp_enable_fit_image');

if(empty($pp_enable_fit_image))
{
$pp_enable_fit_image = 1;
}
else
{
$pp_enable_fit_image = 0;
}
?>
fit_portrait : <?php echo $pp_enable_fit_image; ?>, //Portrait images will not exceed browser height
fit_landscape : <?php echo $pp_enable_fit_image; ?>, //Landscape images will not exceed browser width

//Components
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 0, //Thumbnail navigation
slide_counter : 0, //Display slide numbers
slide_captions : 0, //Slide caption (Pull from "title" in slides array)
progress_bar : 1,
slides : [ //Slideshow Images



<?php
foreach($bg_photo_arr as $key => $photo)
{
$small_image_url = get_stylesheet_directory_uri().'/images/000_70.png';
$hyperlink_url = get_permalink($photo->ID);

if(!empty($photo->guid))
{
$image_url[0] = $photo->guid;
}

?>

<?php $homeslides .= '{image : \''.$image_url[0].'\', thumb: \''.$small_image_url.'\', title: "<div id=\"gallery_title\">'.htmlentities($photo->post_title).'</div><div id=\"gallery_desc\">'.htmlentities($photo->post_content).'</div>"},'; ?>

<?php
}
?>

<?php $homeslides = substr($homeslides,0,-1);
echo $homeslides; ?> ]

});
});

</script>

<div id="thumb-tray" class="load-item">
<div id="thumb-back"></div>
<div id="thumb-forward"></div>
<a id="prevslide" class="load-item"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/arrow_back.png" alt=""/></a>
<a id="nextslide" class="load-item"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/arrow_forward.png" alt=""/></a>
</div>

<div id="progress-back" class="load-item">
<div id="progress-bar"></div>
</div>

<input type="hidden" id="pp_image_path" name="pp_image_path" value="<?php echo get_stylesheet_directory_uri(); ?>/images/"/>

<?php
}
?>

<?php
//Display main gallery contents
if(!empty($all_photo_arr))
{
?>

<?php
//Get social media sharing option
$pp_social_sharing = get_option('pp_social_sharing');

if(!empty($pp_social_sharing))
{
?>
<div class="gallery_social">
<div class="each">
<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&amp;href=<?php echo urlencode($page->guid); ?>&amp;send=false&amp;layout=box_count&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>
</div>
<div class="each">
<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
<div class="each">
<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>

<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
</div>
<?php
}
?>

<div class="page_control">
<a id="page_minimize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>
</a>
<a id="page_maximize" href="#">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>
</a>
</div>

<!-- Begin content -->
<div id="page_content_wrapper">

<div class="inner">

<div class="inner_wrapper">

<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">
<h1 class="cufon"><?php echo $post->post_title; ?></h1>

</div>

<div class="sidebar_content">
<?php
if(!empty($post->post_content))
{
?>
<?php echo pp_apply_content($post->post_content); ?><br/>
<?php
}
?>

<?php
foreach($all_photo_arr as $key => $photo)
{
$small_image_url = get_stylesheet_directory_uri().'/images/000_70.png';
$hyperlink_url = get_permalink($photo->ID);

if(!empty($photo->guid))
{
$image_url[0] = $photo->guid;
$small_image_url = wp_get_attachment_image_src($photo->ID, 'gallery_4', true);
}

$last_class = '';
if(($key+1)%4==0)
{
$last_class = 'last';
}
?>

<div class="one_fourth <?php echo $last_class; ?> gallery4">
<?php
if(!empty($small_image_url))
{
$pp_portfolio_enable_slideshow_title = get_option('pp_portfolio_enable_slideshow_title');
?>
<a class="fancy-gallery" rel="fancybox-thumb" href="<?php echo $image_url[0]; ?>" <?php if(!empty($pp_portfolio_enable_slideshow_title)) { ?>title="<?php echo $photo->post_title; ?>"<?php } ?>>
<img src="<?php echo $small_image_url[0]; ?>" alt="" class="one_fourth_img"/>
</a>
<?php
}
?>

</div>

<?php
}
?>

</div>

</div>
<div class="sidebar_wrapper">
<div class="sidebar">

<div class="content">

<ul class="sidebar_widget">
<?php dynamic_sidebar($page_sidebar); ?>
</ul>

</div>

</div>
<br class="clear"/>

<div class="sidebar_bottom"></div>
</div>
</div>
</div>
<br class="clear"/>
<?php get_footer(); ?>

<?php
}
?>


Please, provide the correct code snippet and advise where to insert it within teh category.php to display a given number of pictures that are attached as gallery to an according page.
Note: I am also using a plugin called "Post Tags and Categories for Pages", although I cannot see that this may have a direct impact I want to mention it.

Answers (4)

2012-09-25

Martin Pham answers:

please try this

insert this into functions.php

function get_product_more_images($offset = 0, $num = 10){
global $post;
$args = array(
'order' => 'ASC',
'orderby' => 'menu_order',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null,
'numberposts' => $num,
'offset' => $offset,
);
$i = 1;
$class = 'more-thumb';
$attachments = get_posts($args);
$images = '';
if ($attachments) {
foreach ($attachments as $attachment) {
if($i == $num) $class .= ' last-thumb';
$images .= wp_get_attachment_image($attachment->ID, 'thumbnail', false, array('class' => $class) );
$i++;
}
}
return $images;
}


so backup and replace category.php


<?php

/**

* The main template file for display category page.

*

* @package WordPress

*/



/**

* Get Current page object

**/
$page = get_page($post->ID);



/**

* Get current page id

**/



if(!isset($current_page_id) && isset($page->ID))

{

$current_page_id = $page->ID;

}



get_header();



//Get Page background style

$pp_blog_bg = get_option('pp_blog_bg');



if(empty($pp_blog_bg))

{

$pp_blog_bg = '/example/bg.jpg';

}

?>

<script type="text/javascript">

jQuery.backstretch( "<?php echo $pp_blog_bg; ?>", {speed: 'slow'} );

</script>



<!-- Begin content -->

<?php

//Get social media sharing option

$pp_social_sharing = get_option('pp_social_sharing');



if(!empty($pp_social_sharing))

{

?>

<div class="gallery_social">

<div class="each">

<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&amp;href=<?php echo urlencode($page->guid); ?>&amp;send=false&amp;layout=box_count&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>

</div>

<div class="each">

<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

</div>

<div class="each">

<!-- Place this tag where you want the +1 button to render -->

<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>



<!-- Place this render call where appropriate -->

<script type="text/javascript">

(function() {

var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;

po.src = 'https://apis.google.com/js/plusone.js';

var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

})();

</script>

</div>

</div>

<?php

}

?>



<div class="page_control">

<a id="page_minimize" href="#">

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>

</a>

<a id="page_maximize" href="#">

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>

</a>

</div>



<div id="page_content_wrapper">

<div class="inner">

<!-- Begin main content -->

<div class="inner_wrapper">

<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">

<h1 class="cufon"><?php printf( __( ' %s', '' ), '' . single_cat_title( '', false ) . '' ); ?></h1>

</div>

<div class="sidebar_content">



<?php



global $more; $more = false; # some wordpress wtf logic



if (have_posts()) : while (have_posts()) : the_post();

?>



<!-- Begin each blog post -->

<div class="post_wrapper">



<?php

if(has_post_thumbnail())

{

?>



<br class="clear"/>

<div class="post_img">

<?php echo get_product_more_images(0,2); ?>

</div>



<?php

}

?>



<br/>

<div class="post_date">

<div class="month"><?php the_time('M'); ?></div>

<div class="date"><?php the_time('j'); ?></div>

<div class="year"><?php the_time('Y'); ?></div>

</div>



<div class="post_header">

<h5 class="cufon"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>

<div class="post_detail">

<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?> on <?php echo get_the_time('d M Y'); ?> /

<a href=""><?php comments_number('0 Comment', '1 Comment', '% Comments'); ?></a>

</div>

</div>

<br class="clear"/>



<?php

$pp_blog_display_full = get_option('pp_blog_display_full');



if(!empty($pp_blog_display_full))

{

the_content();

}

else

{

the_excerpt();

?>



<br/><br/>

<a href="<?php the_permalink(); ?>"><?php echo _e( 'zum Angebot...', THEMEDOMAIN ); ?></a>



<?php

}

?>



</div>



<!-- End each blog post -->

<?php endwhile; endif; ?>



<div class="pagination"><p><?php posts_nav_link(' '); ?></p></div>



</div>



<div class="sidebar_wrapper">



<div class="sidebar_top"></div>



<div class="sidebar">



<div class="content">



<ul class="sidebar_widget">

<?php dynamic_sidebar('Category Sidebar'); ?>

</ul>



</div>



</div>

<br class="clear"/>



<div class="sidebar_bottom"></div>

</div>



</div>

<!-- End main content -->

</div>

</div>

<br class="clear"/>

<?php get_footer(); ?>


fishhit comments:

I tested it, it does not work, no image in category page visible.


Martin Pham comments:

I have to fix it, hopefully it will work well

insert into functions.php

function get_product_more_images($postID, $offset = 0, $num = 10){
if(!$postID) return;
$args = array(

'order' => 'ASC',

'orderby' => 'menu_order',

'post_type' => 'attachment',

'post_parent' => $postID,

'post_mime_type' => 'image',

'post_status' => null,

'numberposts' => $num,

'offset' => $offset,

);

$i = 1;

$class = 'more-thumb';

$attachments = get_posts($args);

$images = '';

if ($attachments) {

foreach ($attachments as $attachment) {

if($i == $num) $class .= ' last-thumb';

$images .= wp_get_attachment_image($attachment->ID, 'thumbnail', false, array('class' => $class) );

$i++;

}

}
return $images;
}


replace category.php

<?php

/**

* The main template file for display category page.

*

* @package WordPress

*/



/**

* Get Current page object

**/
$page = get_page($post->ID);



/**

* Get current page id

**/



if(!isset($current_page_id) && isset($page->ID))

{

$current_page_id = $page->ID;

}



get_header();



//Get Page background style

$pp_blog_bg = get_option('pp_blog_bg');



if(empty($pp_blog_bg))

{

$pp_blog_bg = '/example/bg.jpg';

}

?>

<script type="text/javascript">

jQuery.backstretch( "<?php echo $pp_blog_bg; ?>", {speed: 'slow'} );

</script>



<!-- Begin content -->

<?php

//Get social media sharing option

$pp_social_sharing = get_option('pp_social_sharing');



if(!empty($pp_social_sharing))

{

?>

<div class="gallery_social">

<div class="each">

<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&amp;href=<?php echo urlencode($page->guid); ?>&amp;send=false&amp;layout=box_count&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>

</div>

<div class="each">

<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

</div>

<div class="each">

<!-- Place this tag where you want the +1 button to render -->

<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>



<!-- Place this render call where appropriate -->

<script type="text/javascript">

(function() {

var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;

po.src = 'https://apis.google.com/js/plusone.js';

var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);

})();

</script>

</div>

</div>

<?php

}

?>



<div class="page_control">

<a id="page_minimize" href="#">

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>

</a>

<a id="page_maximize" href="#">

<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>

</a>

</div>



<div id="page_content_wrapper">

<div class="inner">

<!-- Begin main content -->

<div class="inner_wrapper">

<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">

<h1 class="cufon"><?php printf( __( ' %s', '' ), '' . single_cat_title( '', false ) . '' ); ?></h1>

</div>

<div class="sidebar_content">



<?php



global $more; $more = false; # some wordpress wtf logic



if (have_posts()) : while (have_posts()) : the_post();

?>



<!-- Begin each blog post -->

<div class="post_wrapper">



<?php

if(has_post_thumbnail(get_the_ID()))

{

?>



<br class="clear"/>

<div class="post_img">

<?php echo get_product_more_images(get_the_ID(),0,2); ?>

</div>



<?php

}

?>



<br/>

<div class="post_date">

<div class="month"><?php the_time('M'); ?></div>

<div class="date"><?php the_time('j'); ?></div>

<div class="year"><?php the_time('Y'); ?></div>

</div>



<div class="post_header">

<h5 class="cufon"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>

<div class="post_detail">

<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?> on <?php echo get_the_time('d M Y'); ?> /

<a href=""><?php comments_number('0 Comment', '1 Comment', '% Comments'); ?></a>

</div>

</div>

<br class="clear"/>



<?php

$pp_blog_display_full = get_option('pp_blog_display_full');



if(!empty($pp_blog_display_full))

{

the_content();

}

else

{

the_excerpt();

?>



<br/><br/>

<a href="<?php the_permalink(); ?>"><?php echo _e( 'zum Angebot...', THEMEDOMAIN ); ?></a>



<?php

}

?>



</div>



<!-- End each blog post -->

<?php endwhile; endif; ?>



<div class="pagination"><p><?php posts_nav_link(' '); ?></p></div>



</div>



<div class="sidebar_wrapper">



<div class="sidebar_top"></div>



<div class="sidebar">



<div class="content">



<ul class="sidebar_widget">

<?php dynamic_sidebar('Category Sidebar'); ?>

</ul>



</div>



</div>

<br class="clear"/>



<div class="sidebar_bottom"></div>

</div>



</div>

<!-- End main content -->



</div>

</div>

<br class="clear"/>

<?php get_footer(); ?>


fishhit comments:

testeed again, no effect...sorry.


Martin Pham comments:

it work with this (i have checked) . Becase has_post_thumbnail() return false in loop. I've revised


#functions.php

function get_product_more_images($postID, $offset = 0, $num = 10){
if(!$postID && !has_post_thumbnail($postID)) return;
$args = array(

'order' => 'ASC',

'orderby' => 'menu_order',

'post_type' => 'attachment',

'post_parent' => $postID,

'post_mime_type' => 'image',

'post_status' => null,

'numberposts' => $num,

'offset' => $offset,

);

$i = 1;

$class = 'more-thumb';

$attachments = get_posts($args);

$images = '';

if ($attachments) {

foreach ($attachments as $attachment) {

if($i == $num) $class .= ' last-thumb';

$images .= wp_get_attachment_image($attachment->ID, 'thumbnail', false, array('class' => $class) );

$i++;

}

}
return $images;
}



category.php


<?php



/**



* The main template file for display category page.



*



* @package WordPress



*/







/**



* Get Current page object



**/

$page = get_page($post->ID);







/**



* Get current page id



**/







if(!isset($current_page_id) && isset($page->ID))



{



$current_page_id = $page->ID;



}







get_header();







//Get Page background style



$pp_blog_bg = get_option('pp_blog_bg');







if(empty($pp_blog_bg))



{



$pp_blog_bg = '/example/bg.jpg';



}



?>



<script type="text/javascript">



jQuery.backstretch( "<?php echo $pp_blog_bg; ?>", {speed: 'slow'} );



</script>







<!-- Begin content -->



<?php



//Get social media sharing option



$pp_social_sharing = get_option('pp_social_sharing');







if(!empty($pp_social_sharing))



{



?>



<div class="gallery_social">



<div class="each">



<iframe class="facebook_button" src="//www.facebook.com/plugins/like.php?app_id=262802827073639&amp;href=<?php echo urlencode($page->guid); ?>&amp;send=false&amp;layout=box_count&amp;width=200&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:70px;" allowTransparency="true"></iframe>



</div>



<div class="each">



<a href="https://twitter.com/share" data-text="<?php echo $page->post_title; ?>" data-url="<?php echo $page->guid; ?>" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>



</div>



<div class="each">



<!-- Place this tag where you want the +1 button to render -->



<g:plusone size="tall" href="<?php echo $page->guid; ?>"></g:plusone>







<!-- Place this render call where appropriate -->



<script type="text/javascript">



(function() {



var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;



po.src = 'https://apis.google.com/js/plusone.js';



var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);



})();



</script>



</div>



</div>



<?php



}



?>







<div class="page_control">



<a id="page_minimize" href="#">



<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_minus.png" alt=""/>



</a>



<a id="page_maximize" href="#">



<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/icon_plus.png" alt=""/>



</a>



</div>







<div id="page_content_wrapper">



<div class="inner">



<!-- Begin main content -->



<div class="inner_wrapper">



<div id="page_caption" class="sidebar_content full_width" style="padding-bottom:0">



<h1 class="cufon"><?php printf( __( ' %s', '' ), '' . single_cat_title( '', false ) . '' ); ?></h1>



</div>



<div class="sidebar_content">







<?php







global $more; $more = false; # some wordpress wtf logic







if (have_posts()) : while (have_posts()) : the_post();



?>







<!-- Begin each blog post -->



<div class="post_wrapper">







<?php
$thumb = get_product_more_images(get_the_ID(),0,2);
if($thumb)
{

?>







<br class="clear"/>



<div class="post_img">



<?php echo $thumb; ?>



</div>







<?php



}



?>







<br/>



<div class="post_date">



<div class="month"><?php the_time('M'); ?></div>



<div class="date"><?php the_time('j'); ?></div>



<div class="year"><?php the_time('Y'); ?></div>



</div>







<div class="post_header">



<h5 class="cufon"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>



<div class="post_detail">



<?php echo _e( 'Posted by', THEMEDOMAIN ); ?> <?php echo get_the_author(); ?> on <?php echo get_the_time('d M Y'); ?> /



<a href=""><?php comments_number('0 Comment', '1 Comment', '% Comments'); ?></a>



</div>



</div>



<br class="clear"/>







<?php



$pp_blog_display_full = get_option('pp_blog_display_full');







if(!empty($pp_blog_display_full))



{



the_content();



}



else



{



the_excerpt();



?>







<br/><br/>



<a href="<?php the_permalink(); ?>"><?php echo _e( 'zum Angebot...', THEMEDOMAIN ); ?></a>







<?php



}



?>







</div>







<!-- End each blog post -->



<?php endwhile; endif; ?>







<div class="pagination"><p><?php posts_nav_link(' '); ?></p></div>







</div>







<div class="sidebar_wrapper">







<div class="sidebar_top"></div>







<div class="sidebar">







<div class="content">







<ul class="sidebar_widget">



<?php dynamic_sidebar('Category Sidebar'); ?>



</ul>







</div>







</div>



<br class="clear"/>







<div class="sidebar_bottom"></div>



</div>







</div>



<!-- End main content -->







</div>



</div>



<br class="clear"/>



<?php get_footer(); ?>


Martin Pham comments:

Please see attached screenshot for example working