Display both dates in widget
-
Hi!
I would like to display both dates (greg & heb) in the widget area. I have set up the plugin accordingly.
However, it shows only the heb date as a widget.How may I display both dates?
Thanks
Tamás
The page I need help with: [log in to see the link]
-
The plugin not supported it. You can add new widget with this option.
class Bothdate_Widget extends Hebdate_Widget { public function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; } echo date() . ' - ' . today_hebDate(); echo $args['after_widget']; } }Thanks a lot, Hatul!
Where should I put this code and how to use it in a widget area?
Greetings
Tamás
If you add the code to functions.php file then you have new widget.
Thanks!
I have put it at the end of the function.php file of the template.
Like this:require_once( trailingslashit( get_template_directory() ) . ‘inc/functions/enqueue-scripts.php’ );
require_once( trailingslashit( get_template_directory() ) . ‘inc/admin/custom.php’ );
/* hebrew date extension */
class Bothdate_Widget extends Hebdate_Widget {
public function widget( $args, $instance ) {
echo $args[‘before_widget’];
if ( ! empty( $instance[‘title’] ) ) {
echo $args[‘before_title’] . apply_filters( ‘widget_title’, $instance[‘title’] ). $args[‘after_title’];
}
echo date() . ‘ – ‘ . today_hebDate();
echo $args[‘after_widget’];
}
}However, I do not see the new widget to add.
I have read something about registering the widget, as well.
Shouldn’t it be fine, as well?Thanks
Tamás
OK. Add this code:
function register_bothdate_widget() { register_widget( ' Bothdate_Widget' ); } add_action( 'widgets_init', 'register_bothdate_widget' );Thanks again.
However, it gives an error message now:https://photos.app.goo.gl/Z7nLqtSNuVqp51256
🙁
What to do now?
Greetings
Tamás
Try the new version of the plugin. The date format in the widget shown by the settings.
Beautiful!
It really works now!
For me and for everyone!
Very nice!Thanks a lot!
The topic ‘Display both dates in widget’ is closed to new replies.