diff --git a/functions.php b/functions.php index 716c2d5..7b2b2b6 100644 --- a/functions.php +++ b/functions.php @@ -64,6 +64,14 @@ function Hefz_Register_Widget(){ 'before_widget' => '
', 'after_widget' => "
\n", ) ); + + register_sidebar( array( + 'name' => __('سایدر سایت'), + 'id' => 'sidbar-widget', + 'description' => __('این بخش مربوط به ساید بار سایت میباشد'), + 'before_widget' => '
', + 'after_widget' => "
\n", + ) ); } add_action('widgets_init', 'Hefz_Register_Widget'); @@ -96,3 +104,76 @@ function custom_breadcrumbs() { 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 ); + ?> +
+ + have_posts() ) { + while ( $the_query->have_posts() ) { + $the_query->the_post();?> +
+ +

+
+ +
+ + + + + > + -
- \ No newline at end of file diff --git a/sidebar.php b/sidebar.php index 149249e..37e14c7 100644 --- a/sidebar.php +++ b/sidebar.php @@ -1,23 +1,10 @@ \ No newline at end of file