اضافه کردن ابزارک اختصاصی آخرین مطلب
و پایان داینامیک کردن page
This commit is contained in:
parent
0741d8ae89
commit
54804943ac
@ -64,6 +64,14 @@ function Hefz_Register_Widget(){
|
|||||||
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
||||||
'after_widget' => "</div>\n",
|
'after_widget' => "</div>\n",
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
register_sidebar( array(
|
||||||
|
'name' => __('سایدر سایت'),
|
||||||
|
'id' => 'sidbar-widget',
|
||||||
|
'description' => __('این بخش مربوط به ساید بار سایت میباشد'),
|
||||||
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
||||||
|
'after_widget' => "</div>\n",
|
||||||
|
) );
|
||||||
}
|
}
|
||||||
add_action('widgets_init', 'Hefz_Register_Widget');
|
add_action('widgets_init', 'Hefz_Register_Widget');
|
||||||
|
|
||||||
@ -96,3 +104,76 @@ function custom_breadcrumbs() {
|
|||||||
echo 'نتایج جستجو برای "' . get_search_query() . '"';
|
echo 'نتایج جستجو برای "' . get_search_query() . '"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Hefz_Register_Widget_Post extends WP_Widget {
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
// Instantiate the parent object.
|
||||||
|
parent::__construct( false, __( 'حفظ | ابزارک آخرین مطالب') );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function widget( $args, $instance ) {
|
||||||
|
|
||||||
|
//شروع بخش آخرین مقالات
|
||||||
|
$args = array('post_type' => 'post',
|
||||||
|
'posts_per_page' => $instance['recentcont']
|
||||||
|
);
|
||||||
|
$query = new WP_Query($args);
|
||||||
|
// The Query.
|
||||||
|
$the_query = new WP_Query( $args );
|
||||||
|
?>
|
||||||
|
<div class="sidebar-related-post">
|
||||||
|
<span class="last-post-title"><?php echo $instance['recenttitle']?></span>
|
||||||
|
<?php
|
||||||
|
// The Loop.
|
||||||
|
if ( $the_query->have_posts() ) {
|
||||||
|
while ( $the_query->have_posts() ) {
|
||||||
|
$the_query->the_post();?>
|
||||||
|
<div class="item-post">
|
||||||
|
<a href="<?php the_permalink();?>"><?php the_post_thumbnail();?></a>
|
||||||
|
<a href="<?php the_permalink();?>"><h3 class="title-post"><?php the_title();?></h3></a>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
esc_html_e( 'پستی برای نمایش وجود ندارد' );
|
||||||
|
}
|
||||||
|
// Restore original Post Data.
|
||||||
|
wp_reset_postdata();
|
||||||
|
//پایان آخرین مقالات
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function update( $new_instance, $old_instance ) {
|
||||||
|
$instance = $old_instance;
|
||||||
|
$instance ['recenttitle'] = $new_instance ['recenttitle'];
|
||||||
|
$instance ['recentcont'] = $new_instance ['recentcont'];
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function form( $instance ) {
|
||||||
|
$title = !empty($instance['recenttitle']) ? $instance['recenttitle'] : 'آخرین مطالب';
|
||||||
|
$cont = !empty($instance['recentcont']) ? $instance['recentcont'] : 4;
|
||||||
|
?>
|
||||||
|
<label for="">عنوان پست ها</label>
|
||||||
|
<input type="text" name="<?php echo $this->get_field_name('recenttitle');?>" id="<?php echo $this->get_field_id('recenttitle');?>" value="<?php echo $title?>">
|
||||||
|
<label for="">تعداد پست ها</label>
|
||||||
|
<input type="number" name="<?php echo $this->get_field_name('recentcont');?>" id="<?php echo $this->get_field_id('recentcont');?>" value=<?php echo $cont?>>
|
||||||
|
<?php
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action( 'widgets_init', 'function_Hefz_Register_Widget_Post' );
|
||||||
|
|
||||||
|
|
||||||
|
function function_Hefz_Register_Widget_Post() {
|
||||||
|
register_widget('Hefz_Register_Widget_Post');
|
||||||
|
}
|
@ -328,6 +328,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"></div>
|
|
||||||
</div>
|
|
||||||
<?php get_footer();?>
|
<?php get_footer();?>
|
29
sidebar.php
29
sidebar.php
@ -1,23 +1,10 @@
|
|||||||
<aside class="kitkala-sidebar">
|
<aside class="kitkala-sidebar">
|
||||||
<a href="#"><img src="assets/img/ads.png" alt=""></a>
|
|
||||||
<div class="sidebar-related-post">
|
|
||||||
<span class="last-post-title">آخرین نوشته ها</span>
|
<?php
|
||||||
<div class="item-post">
|
if(is_active_sidebar('sidbar-widget')){
|
||||||
<a href="#"><img src="assets/img/sidebar-thum.png" alt=""></a>
|
dynamic_sidebar('sidbar-widget');
|
||||||
<a href="#"><h3 class="title-post">بهترین گوشی سامسونگ</h3></a>
|
}
|
||||||
</div>
|
?>
|
||||||
<div class="item-post">
|
|
||||||
<a href="#"><img src="assets/img/sidebar-thum2.png" alt=""></a>
|
|
||||||
<a href="#"><h3 class="title-post">گوشی نوت 11 پرو به زودی وارد بازار می شود</h3></a>
|
|
||||||
</div>
|
|
||||||
<div class="item-post">
|
|
||||||
<a href="#"><img src="assets/img/sidebar-thum.png" alt=""></a>
|
|
||||||
<a href="#"><h3 class="title-post">بهترین گوشی سامسونگ</h3></a>
|
|
||||||
</div>
|
|
||||||
<div class="item-post">
|
|
||||||
<a href="#"><img src="assets/img/sidebar-thum2.png" alt=""></a>
|
|
||||||
<a href="#"><h3 class="title-post">گوشی نوت 11 پرو به زودی وارد بازار می شود</h3></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a href="#"><img src="assets/img/side-img.png" alt=""> </a>
|
|
||||||
</aside>
|
</aside>
|
Loading…
x
Reference in New Issue
Block a user