Ejemplo n.º 1
0
function _wpbdp_template_mode($template)
{
    if (wpbdp_locate_template(array('businessdirectory-' . $template, 'wpbusdirman-' . $template), true, false)) {
        return 'template';
    }
    return 'page';
}
 public function _single_template($template)
 {
     if (is_single() && get_post_type() == WPBDP_POST_TYPE) {
         return wpbdp_locate_template(array('businessdirectory-single', 'wpbusdirman-single'));
     }
     return $template;
 }
Ejemplo n.º 3
0
 public function view_listings($include_buttons = false, $args_ = array())
 {
     $paged = 1;
     if (get_query_var('page')) {
         $paged = get_query_var('page');
     } elseif (get_query_var('paged')) {
         $paged = get_query_var('paged');
     }
     $args = array('post_type' => WPBDP_POST_TYPE, 'posts_per_page' => wpbdp_get_option('listings-per-page') > 0 ? wpbdp_get_option('listings-per-page') : -1, 'post_status' => 'publish', 'paged' => intval($paged), 'orderby' => wpbdp_get_option('listings-order-by', 'date'), 'order' => wpbdp_get_option('listings-sort', 'ASC'));
     if (isset($args_['numberposts'])) {
         $args['numberposts'] = $args_['numberposts'];
     }
     // See if we need to call query_posts() directly in case the user is using the template without
     // the $query argument.
     $template = file_get_contents(wpbdp_locate_template('businessdirectory-listings'));
     $compat = false === stripos($template, '$query->the_post') ? true : false;
     if ($compat) {
         query_posts($args);
         $q = $GLOBALS['wp_query'];
     } else {
         $q = new WP_Query($args);
     }
     wpbdp_push_query($q);
     $html = wpbdp_capture_action('wpbdp_before_viewlistings_page');
     $html .= wpbdp_render('businessdirectory-listings', array('query' => $q, 'excludebuttons' => !$include_buttons), true);
     $html .= wpbdp_capture_action('wpbdp_after_viewlistings_page');
     if (!$compat) {
         wp_reset_postdata();
     }
     wp_reset_query();
     wpbdp_pop_query($q);
     return $html;
 }