Elimde su sitedeki widget gibi bir widget
var. Bunu herhangi bir temaya nasil ekleyebilirim Arkadaslar? bu konuda yardimci olabilirseniz cok sevinirim.
Widget anasayfada cikacak.
simdiden tesekkürler.
widgetin icerigi:
add_action('widgets_init', 'pyre_homepage_2col_load_widgets');
function pyre_homepage_2col_load_widgets()
{
register_widget('Pyre_Homepage_2col_Widget');
}
class Pyre_Homepage_2col_Widget extends WP_Widget {
function Pyre_Homepage_2col_Widget()
{
$widget_ops = array('classname' => 'pyre_homepage_2col', 'description' => 'Homepage 2-column recent posts widget.');
$control_ops = array('id_base' => 'pyre_homepage_2col-widget');
$this->WP_Widget('pyre_homepage_2col-widget', 'Avenue Theme: Home 2-column', $widget_ops, $control_ops);
}
function widget($args, $instance)
{
extract($args);
$show_excerpt = isset($instance['show_excerpt']) ? 'true' : 'false';
$title = $instance['title'];
$post_type = 'all';
$categories = $instance['categories'];
$posts = $instance['posts'];
$images = true;
$title_2 = $instance['title_2'];
$post_type_2 = 'all';
$categories_2 = $instance['categories_2'];
$posts_2 = $instance['posts_2'];
$images_2 = true;
echo $before_widget;
?>
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
if($post_type == 'all') {
$post_type_array = $post_types;
} else {
$post_type_array = $post_type;
}
?>
»
$recent_posts = new WP_Query(array(
'showposts' => $posts,
'cat' => $categories,
));
?>
have_posts()): $recent_posts->the_post(); ?>
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '';
} else {
$icon = '';
}
?>
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
if($post_type_2 == 'all') {
$post_type_2_array = $post_types;
} else {
$post_type_2_array = $post_type;
}
?>
»
$recent_posts = new WP_Query(array(
'showposts' => $posts_2,
'cat' => $categories_2,
));
?>
have_posts()): $recent_posts->the_post(); ?>
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '';
} else {
$icon = '';
}
?>
echo $after_widget;
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['show_excerpt'] = $new_instance['show_excerpt'];
$instance['title'] = $new_instance['title'];
$instance['post_type'] = 'all';
$instance['categories'] = $new_instance['categories'];
$instance['posts'] = $new_instance['posts'];
$instance['show_images'] = true;
$instance['title_2'] = $new_instance['title_2'];
$instance['post_type_2'] = 'all';
$instance['categories_2'] = $new_instance['categories_2'];
$instance['posts_2'] = $new_instance['posts_2'];
$instance['show_images_2'] = true;
return $instance;
}
function form($instance)
{
$defaults = array('show_excerpt' => null, 'title' => 'Recent Posts', 'post_type' => 'all', 'categories' => 'all', 'posts' => 4, 'title_2' => 'Recent Posts', 'post_type_2' => 'all', 'categories_2' => 'all', 'posts_2' => 4);
$instance = wp_parse_args((array) $instance, $defaults); ?>
id="get_field_id('show_excerpt'); ?>" name="get_field_name('show_excerpt'); ?>" />
Column One
Column Two
}
?>