Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( !function_exists( 'shortcode_bethlehem_recent_posts_widget' ) ) {
- function shortcode_bethlehem_recent_posts_widget( $atts = array(), $content = null ) {
- $default_atts = array(
- 'title' => '',
- 'pre_title' => '',
- 'limit' => '',
- 'type' => '',
- 'show_date' => '',
- 'el_class' => '',
- );
- extract( array_merge( $default_atts, $atts ) );
- $widget = 'Bethlehem_Widget_Recent_Posts';
- $instance = array(
- 'title' => $title,
- 'type' => $type,
- 'number' => $limit,
- 'show_date' => $show_date,
- );
- $before_widget = '<div class="widget vc_widget_recent_posts ' . esc_attr( $type ) .' '. esc_attr( $el_class ) . '">';
- $after_widget = '</div>';
- if( !empty( $pre_title ) ) {
- $before_title = '<h3 class="pre-title">'.$pre_title.'</h3><h3 class="widget-title">';
- $after_title = '</h3>';
- } else {
- $before_title = '<h3 class="widget-title">';
- $after_title = '</h3>';
- }
- $args = array(
- 'before_widget' => $before_widget,
- 'after_widget' => $after_widget,
- 'before_title' => $before_title,
- 'after_title' => $after_title
- );
- $output = '';
- add_action( 'pre_get_posts', 'custom_blog_widget_category' );
- ob_start();
- the_widget( $widget, $instance, $args );
- $output .= ob_get_clean();
- remove_action( 'pre_get_posts', 'custom_blog_widget_category' );
- return apply_filters( 'shortcode_beth_recent_posts_widget' , $output );
- }
- }
- function custom_blog_widget_category( $query ) {
- $query->set( 'cat', '7'); // Add your category id here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement