
نوشته اصلی توسط
T.Toosi
سلام، آیدی category رو پیدا و جایگزین کد زیر کنید :
کد PHP:
$args = array('parent' => 17);
$categories = get_categories( $args );
foreach($categories as $category) {
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
echo '<p> Description:'. $category->description . '</p>';
echo '<p> Post Count: '. $category->count . '</p>';
}
ممنون کار کرد
ولی بعد از چاپ دسته بندی و بقیه مواردی که توی کد هست دیگه بقیه سایت نشون داده نمیشه
معلوم نیست مشکل از کجاست؟
این هم آدرس سایت
http://khabareparsi.com/test/
- - - Updated - - -
کد PHP:
<?php $manba_khabar = get_post_meta($post->ID, 'manba_khabar', true); ?><?phpadd_action( 'widgets_init', 'wp_posts_box_12_widget' );function wp_posts_box_12_widget() { register_widget( 'wp_posts_box_12' );}
class wp_posts_box_12 extends WP_Widget {
function wp_posts_box_12() { $widget_ops = array( 'classname' => 'posts-box_12','description' => 'جهت استفاده در سایدبار اصلی' ); $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'posts-box-12-widget' ); parent::__construct( 'posts-box-12-widget',theme_name .' - '. __( 'باکس دوازدهم مطالب ' , 'wp'), $widget_ops, $control_ops ); } function widget( $args, $instance ) { extract( $args ); if ( isset( $instance[ 'category_link' ] ) ) { $category_link = $instance[ 'category_link' ]; }
if ( isset( $instance[ 'category_target' ] ) ) { $category_target = $instance[ 'category_target' ]; }
$title = $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); $category = $instance['category']; $number = $instance['number']; $icon_code = apply_filters( 'icon_code', $instance['icon_code'] ); ?>
<div class="boxe"> <div class="boxe-1-title"> <span><?php echo $icon_code; ?> <?php echo $title; ?></span> <b><a href="<?php echo $category_link; ?>"<?php if($category_target == "on") echo " target=\"_blank\""; ?>> <?php echo get_option('qaleb_bishtar'); ?> </a></b> </div> <div class="boxe-2-top"> <?php $my_query = new WP_Query('showposts=1&cat='.$category); while ($my_query->have_posts()): $my_query->the_post(); ?> <div class="boxe-2-top-r"> <a href="<?php the_permalink(); ?>"><div class="boxe-2-top-images"><img src="<?php the_post_thumbnail_url('img-1'); ?>" alt="<?php the_title(); ?>"></div></a> <span class="boxe-2-top-date"><?php the_time('d M Y'); ?></span> </div> <div class="boxe-2-top-l"> <div class="boxe-2-top-title"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a><?php echo $manba_khabar; ?><div style="display: -webkit-box;padding-top: 5px;"><div style="padding-left: 19px;" class="box-12-category"><?php$args = array('parent' => 301);$categories = get_categories( $args );foreach($categories as $category) { echo '<p><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "نمایش همه خبر های %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';} ?> </div><div style="padding-left: 19px;color: #949494;"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' قبل'; ?></div></div></div><br> <div class="boxe-2-top-excerpt"><a><?php echo get_excerpt(490); ?></a></div> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> </div> <div class="boxe-2-bottom"> <?php $my_query = new WP_Query('showposts=6&cat='.$category.'&offset=1'); while ($my_query->have_posts()): $my_query->the_post(); ?> <div class="last-post-12"> <div class="boxe-12-bottom-txt"><a href="<?php the_permalink() ?>" target="_blank"><?php the_title(); ?></a></div><div style="text-align: left;"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' قبل'; ?></div> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> </div> </div>
<?php }
function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = wp_strip_all_tags( $new_instance['title'] ); $instance['category'] = wp_strip_all_tags( $new_instance['category'] ); $instance['category_link'] = wp_strip_all_tags( $new_instance['category_link'] ); $instance['category_target'] = wp_strip_all_tags( $new_instance['category_target'] ); $instance['icon_code'] = ( ! empty( $new_instance['icon_code'] ) ) ? $new_instance['icon_code'] : ''; return $instance; }
function form( $instance ) { $defaults = array( 'title' => '', 'category' => '', 'number' => 5, 'show_date' => '' ); $instance = wp_parse_args( ( array ) $instance, $defaults ); $title = $instance['title']; $category = $instance['category']; $category_link = $instance['category_link']; $category_target = $instance['category_target']; if ( isset( $instance[ 'icon_code' ] ) ) { $icon_code = $instance[ 'icon_code' ]; } ?> <p> <?php $icon_url = esc_url( get_template_directory_uri().( '/images/box/12.png' ) ); ?> <center><img src="<?php echo $icon_url; ?>" alt="" /></center> </p> <p><em style="color:#0073aa;"><?php echo 'توجه : '; ?></em></p> <p><em style="color:#0085ba;"><?php echo 'از این ابزارک بی نهایت باکس بسازید.'; ?></em></p> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'عنوان' ); ?>:</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>" /> </p> <p> <p>کد آیکن مورد نظر را برای این ابزارک از این <a target="_blank" href="http://fontawesome.io/icons"><em style="color:#0073aa;"> لینک </em></a>دریافت و در کادر زیر قرار دهید</p> <textarea name="<?php echo $this->get_field_name( 'icon_code' ); ?>" placeholder="کد HTML" id="<?php echo $this->get_field_id( 'icon_code' ); ?>" class="widefat" style="direction:ltr;height:50px;"><?php echo esc_attr( $icon_code ); ?></textarea> </p> <p> <label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'انتخاب دسته' ); ?>:</label> <?php
wp_dropdown_categories( array(
'orderby' => 'title', 'hide_empty' => false, 'name' => $this->get_field_name( 'category' ), 'id' => $this->get_field_id( 'category' ), 'class' => 'widefat', 'selected' => $category
) );
?>
</p> <p> <label for="<?php echo $this->get_field_id( 'category_link' ); ?>">لینک مطالب بیشتر :</label> <input type="text" name="<?php echo $this->get_field_name( 'category_link' ); ?>" placeholder="http://...." value="<?php echo esc_attr( $category_link ); ?>" id="<?php echo $this->get_field_id( 'category_link' ); ?>" class="widefat" style="direction:ltr;"> </p> <p> <input type="checkbox" name="<?php echo $this->get_field_name( 'category_target' ); ?>" id="<?php echo $this->get_field_id( 'category_target' ); ?>" class="checkbox" <?php checked( $category_target, "on" ); ?>> <label for="<?php echo $this->get_field_id( 'category_target' ); ?>">در زبانه جدید باز شود</label> </p> <?php }}?>
این هم کد کامل فایل
- - - Updated - - -

نوشته اصلی توسط
T.Toosi
سلام، آیدی category رو پیدا و جایگزین کد زیر کنید :
کد PHP:
$args = array('parent' => 17);
$categories = get_categories( $args );
foreach($categories as $category) {
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
echo '<p> Description:'. $category->description . '</p>';
echo '<p> Post Count: '. $category->count . '</p>';
}
راهی نیست واسه فهمیدن مشکلش؟