رفتن به مطلب

مشکل با single.php


پست های پیشنهاد شده

سلام

من در تمتم صفحات داخلی با این ژیام روبرو میشم :

Fatal error: Class 'Attachments' not found in /home/safiran1/public_html/wp-content/themes/23-Setayesh-2sweb.ir/single.php on line 38

من فایل single را در زیر گذاشتم میشه بررسی کنید.

<?php get_header();?>

<div id="content-wrapper">

<?php include(TEMPLATEPATH.'/ticker.php'); ?>

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

<?php get_sidebar();?>

<div id="main-content">

<?php if(have_posts()): while(have_posts()): the_post();?>

<div class="box">

<h3 class="box-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>

<div class="box-content">

<div class="post">

<div class="post-content">

<?php the_content();?>

<?php

$download_text = get_post_custom_values("download_text");

$download_links = get_post_custom_values("download_link");

$download_count = count($download_links) - 1;

if($download_links[0]) {

?>

<div id="download-wrapper"> <span>دریافت فایل های صوتی : </span>

<ul>

<?php

for($i=0;$i<=$download_count;$i++) {

$download = "";

$download .= '<li><a target="_blank" href="'.$download_links[$i].'">'.$download_text[$i].'</a></li>';

echo $download;

}

?>

</ul>

<?php $download_full = get_post_custom_values("download_full"); if($download_full[0]) { ?>

<span>دریافت فایل (بصورت فشرده) : </span> <a class="total-download" href="<?php echo $download_full;?>">دریافت کل جلسه - کلیک کنید</a>

<?php } ?>

</div>

<!--#download-wrapper-->

<?php } ?>

</div>

<!--.post-content-->

<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>

<?php if( $attachments->exist() ) : ?>

<ul class="box-list gallery clearfix">

<?php $counter=1; while( $attachments->get() ) : ?>

<li><a href="<?php echo $attachments->src( 'full' ); ?>" rel="prettyPhoto[gallery1]" class="box-thumb"><img src="<?php echo $attachments->src( 'full' ); ?>" alt="<?php echo $attachments->field( 'title' ); ?>" /></a>

<h5 class="thumb-title"><?php echo $attachments->field( 'title' ); ?></h5>

</li>

<?php if(!($counter%4)) { ?>

<li class="clear"></li>

<?php } $counter++; endwhile; ?>

</ul>

<?php endif; ?>

<ul class="post-meta">

<li>تعداد بازدید : <span><?php $post_views=get_post_custom_values("post-views"); echo $post_views[0];?></span></li>

<li>دسته بندی : <?php the_category(', ');?></li>

<li>کلمات کلیدی : <?php the_tags('',',','');?></li>

<li>تاریخ نگارش : <span><?php the_date('Y/m/j');?></span></li>

</ul>

<!--.post-meta-->

</div>

<!--.post-->

</div>

<!--.box-content-->

</div>

<!--.box-->

<?php if(get_option('tsweb_related')=='true') { ?>

<div class="box">

<h3 class="box-title">مطالب مرتبط</h3>

<div class="box-content">

<div class="related-post">

<ul>

<?php

$tags = wp_get_post_tags($post->ID);

if ($tags) {

$tag_ids = array();

foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;

$args=array(

'tag__in' => $tag_ids,

'post__not_in' => array($post->ID),

'showposts'=>get_option('tsweb_related_count'),

'caller_get_posts'=>1

);

$my_query = new wp_query($args);

if( $my_query->have_posts() ) {

while ($my_query->have_posts()) :

$my_query->the_post();

?>

<li>

<h4><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>

</li>

<?php

endwhile;

}else{

?>

<li>مطلب مرتبطی پیدا نشد.</li>

<?php

}

wp_reset_query();

} else {

?>

<li>مطلب مرتبطی پیدا نشد.</li>

<?php

}

?>

</ul>

</div>

<!--.related-post-->

</div>

<!--.box-content-->

</div>

<!--.box-->

<?php } if(get_option('tsweb_comment')=='true') { ?>

<div class="box">

<h3 class="box-title">نظرات کاربران</h3>

<div class="box-content">

<div id="twosweb-comment"> <!-- You can start editing here. -->

<?php comments_template('',true);?>

</div>

<!--#2sweb-comment-->

</div>

<!--.box-content-->

</div>

<!--.box-->

<?php } endwhile; endif;?>

</div>

<!--#main-content-->

</div>

<!--#content-wrapper-->

<?php get_footer();?>

لینک به ارسال

در اینجاست:


<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>

از اول همینطوری بوده یا جدیداً ایجادش کردید؟ گرچه کلاً نیازی به تعریف کلاس براش نیست - اما اینطور که مشخصه کلاس براش تعریف کردید، پس در جایی باید قرار بدید. کجا قرارش دادید؟

  • امتیاز 4
لینک به ارسال

همونطوری که فرمودند در قالبتون برای attachments یک کلاس تعریف کرده و یک حلقه براش ساخته تا بتونه تصاویر پیوست شده را با عناوینشون نمایش بده بجای


<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
<?php if( $attachments->exist() ) : ?>
<ul class="box-list gallery clearfix">
<?php $counter=1; while( $attachments->get() ) : ?>
<li><a href="<?php echo $attachments->src( 'full' ); ?>" rel="prettyPhoto[gallery1]" class="box-thumb"><img src="<?php echo $attachments->src( 'full' ); ?>" alt="<?php echo $attachments->field( 'title' ); ?>" /></a>
<h5 class="thumb-title"><?php echo $attachments->field( 'title' ); ?></h5>
</li>
<?php if(!($counter%4)) { ?>
<li class="clear"></li>
<?php } $counter++; endwhile; ?>
</ul>
<?php endif; ?>

کدهای زیر رو بگذارید و تست کنید


<?php
$args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' =>'any', 'post_parent' => $post->ID );
$attachments = get_posts( $args );
if ( $attachments ) {
$counter=1;
foreach ( $attachments as $attachment ) { ?>
<li><a href="<?php echo $attachments->src( 'full' ); ?>" rel="prettyPhoto[gallery1]" class="box-thumb"><img src="<?php echo $attachments->src( 'full' ); ?>" alt="<?php echo $attachments->field( 'title' ); ?>" /></a>
<h5 class="thumb-title"><?php echo $attachments->field( 'title' ); ?></h5>
</li>
<?php if(!($counter%4)) { ?>
<li class="clear"></li>
<?php } $counter++;
}
}
?>

  • امتیاز 3
لینک به ارسال

لطفا برای ارسال دیدگاه وارد شوید

شما بعد از اینکه وارد حساب کاربری خود شدید می توانید دیدگاهی ارسال کنید



ورود به حساب کاربری
×
×
  • اضافه کردن...