function wp_corenavi() { global $wp_query; $pages = ''; $max = $wp_query->max_num_pages; if (!($current = get_query_var('paged'))) { $current = 1; } $a['base'] = str_replace(999999999, '%#%', get_pagenum_link(999999999)); $a['total'] = $max; $a['current'] = $current; $total = 1; //1 - выводить текст "Страница N из N", 0 - не выводить $a['mid_size'] = 3; //сколько ссылок показывать слева и справа от текущей $a['end_size'] = 1; //сколько ссылок показывать в начале и в конце $a['prev_text'] = '«'; //текст ссылки "Предыдущая страница" $a['next_text'] = '»'; //текст ссылки "Следующая страница" if ($max > 1) { echo '<div class="navigation">'; } if ($total == 1 && $max > 1) { $pages = '<span class="pages">Страница ' . $current . ' из ' . $max . '</span>' . "\r\n"; } echo $pages . paginate_links($a); if ($max > 1) { echo '</div>'; } }
function bap_ajaxP_loop($offset = '') { global $wp_query; $paged = get_query_var('page') ? get_query_var('page') : 1; $do_not_duplicate = array(); // OFFSET SETTING if (!$offset == '' || !$offset == '0') { $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish'); $hide_to_array = get_posts($argshidepost); // HIDE OFFSETED POSTS if ($hide_to_array) { foreach ($hide_to_array as $post) { $do_not_duplicate[] = $post->ID; } } } $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate); $wp_query = new WP_Query($argsmain); if ($wp_query->have_posts()) { echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">'; while ($wp_query->have_posts()) { $wp_query->the_post(); get_template_part('partials/listitem'); } echo '</section>'; } wp_reset_postdata(); }
/** * Display navigation to next/previous set of posts when applicable. * * @since Farmtoyou 1.0 * * @global WP_Query $wp_query WordPress Query object. * @global WP_Rewrite $wp_rewrite WordPress Rewrite object. */ function farmtoyou_paging_nav() { global $wp_query, $wp_rewrite; // Don't print empty markup if there's only one page. if ($wp_query->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'farmtoyou'), 'next_text' => __('Next →', 'farmtoyou'))); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <div class="pagination loop-pagination"> <?php echo $links; ?> </div><!-- .pagination --> </nav><!-- .navigation --> <?php } }
function page_navi($before = '', $after = '') { global $wpdb, $wp_query; $request = $wp_query->request; $posts_per_page = intval(get_query_var('posts_per_page')); $paged = intval(get_query_var('paged')); $numposts = $wp_query->found_posts; $max_page = $wp_query->max_num_pages; if ($numposts <= $posts_per_page) { return; } if (empty($paged) || $paged == 0) { $paged = 1; } $pages_to_show = 3; $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if ($end_page - $start_page != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $max_page) { $start_page = $max_page - $pages_to_show_minus_1; $end_page = $max_page; } if ($start_page <= 0) { $start_page = 1; } echo $before . '<div class="pagination_wrapper"><ul class="pagination">' . ""; if ($paged > 1) { $first_page_text = "First"; echo '<li class="prev"><a href="' . get_pagenum_link() . '" title="First">' . $first_page_text . '</a></li>'; } $prevposts = get_previous_posts_link('Prev'); if ($prevposts) { echo '<li>' . $prevposts . '</li>'; } else { echo '<li class="disabled"><a href="#">Prev</a></li>'; } for ($i = $start_page; $i <= $end_page; $i++) { if ($i == $paged) { echo '<li class="active"><a href="#">' . $i . '</a></li>'; } else { echo '<li><a href="' . get_pagenum_link($i) . '">' . $i . '</a></li>'; } } if ($end_page < $max_page) { $last_page_text = $max_page; echo '<li class="next"><a href="' . get_pagenum_link($max_page) . '" title="Last">' . $last_page_text . '</a></li>'; } echo '<li class="">'; next_posts_link('Next'); echo '</li>'; echo '</ul></div>' . $after . ""; }
/** * Hook into the query parsing to detect oEmbed requests. * * If an oEmbed request is made, trigger the output. * * @codeCoverageIgnore * * @param WP_Query $wp_query The WP_Query instance (passed by reference). */ public function parse_query($wp_query) { // Check for required params. if (false === $wp_query->get('oembed', false)) { return; } if (false === $wp_query->get('url', false)) { status_header(400); echo 'URL parameter missing'; exit; } /** * Check for the allowed query vars and set defaults. * * @see WP_REST_oEmbed_Controller::register_routes() */ $url = esc_url_raw(get_query_var('url')); $format = sanitize_text_field(get_query_var('format', 'json')); /** * Filter the maxwidth oEmbed parameter. * * @param int $maxwidth Maximum allowed width. Defaults to 600. * * @return int */ $maxwidth = apply_filters('oembed_default_width', 600); $maxwidth = get_query_var('maxwidth', $maxwidth); $callback = get_query_var('_jsonp', false); $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback); echo $this->dispatch($request); exit; }
public function pagination($total = -1, $spread = -1) { global $wp_query; $big = 999999999; // need an unlikely integer $current = max(1, get_query_var('paged')); if ($total < 1) { $total = $wp_query->max_num_pages; } if ($spread < 1) { $spread = self::DEFAULT_PAGINATION_SPREAD; } $spread_left = min($current - 1, $spread * 2); $spread_right = min($current + $spread * 2, $total) - $current; if ($spread_left + $spread_right > 4) { if ($spread_left >= 2 && $spread_right >= 2) { $spread_left = $spread_right = 2; } elseif ($spread_left < 2) { $spread_right = 4 - $spread_left; } else { $spread_left = 4 - $spread_right; } } $pages = range($current - $spread_left, $current + $spread_right); $links = array_map(function ($n) use($current) { return '<li>' . ($n == $current ? "<span>{$current}</span>" : sprintf('<a href="%s">%s</a>', get_pagenum_link($n), $n)) . '</li>'; }, $pages); $out = '<nav class="pagination">'; $out .= sprintf('<a class="edge edge--left" href="%s">First</a>', get_pagenum_link(1)); $out .= sprintf('<ul class="nav-menu">%s</ul>', implode('', $links)); $out .= sprintf('<a class="edge edge--right" href="%s">Last</a>', get_pagenum_link($total)); $out = '</nav>'; return $out; }
function expose_homepage_post_class($classes) { global $loop_counter; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $classes[] = 'portfolio-posts'; return $classes; }
/** * Page titles */ function stachestack_title() { if (is_home()) { if (get_option('page_for_posts', true)) { $title = get_the_title(get_option('page_for_posts', true)); } else { $title = __('Latest Posts', 'stachestack'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { $title = apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { $title = apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { $title = sprintf(__('Daily Archives: %s', 'stachestack'), get_the_date()); } elseif (is_month()) { $title = sprintf(__('Monthly Archives: %s', 'stachestack'), get_the_date('F Y')); } elseif (is_year()) { $title = sprintf(__('Yearly Archives: %s', 'stachestack'), get_the_date('Y')); } elseif (is_author()) { $title = sprintf(__('Author Archives: %s', 'stachestack'), get_queried_object()->display_name); } else { $title = single_cat_title('', false); } } elseif (is_search()) { $title = sprintf(__('Search Results for %s', 'stachestack'), get_search_query()); } elseif (is_404()) { $title = __('Not Found', 'stachestack'); } else { $title = get_the_title(); } return apply_filters('stachestack_title', $title); }
function roots_nice_search_redirect() { if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) { wp_redirect(home_url('/search/' . str_replace(array(' ', '%20'), array('+', '+'), get_query_var('s')))); exit; } }
/** * Display navigation to next/previous set of posts when applicable. * * @return void */ function my_simone_paging_nav() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } $paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1; $pagenum_link = html_entity_decode(get_pagenum_link()); $query_args = array(); $url_parts = explode('?', $pagenum_link); if (isset($url_parts[1])) { wp_parse_str($url_parts[1], $query_args); } $pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link); $pagenum_link = trailingslashit($pagenum_link) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%'; // Set up paginated links. $links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list')); if ($links) { ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e('Posts navigation', 'my-simone'); ?> </h1> <?php echo $links; ?> </nav><!-- .navigation --> <?php } }
/** * Handle any query args that come from the requested URL. * * @access protected * * @param mixed $query Query string. * @return array Query arguments */ protected function process_query_args($query) { // Handle requests for paged events. $paged = get_query_var('paged'); if (2 <= $paged) { $query['paged'] = $paged; } // Filter by organizer ID if an "author archive" (organizer events) was requested. $organizer_id = get_query_var('organizer_id'); if (empty($query['organizer_id']) && !empty($organizer_id)) { $query['organizer_id'] = (int) $organizer_id; } // Filter by venue ID if a venue archive (all events at a certain venue) was requested. $venue_id = get_query_var('venue_id'); if (empty($query['venue_id']) && !empty($venue_id)) { $query['venue_id'] = (int) $venue_id; } // Filter by category ID if a category archive (all events in a certain category) was requested. $category_id = get_query_var('category_id'); if (empty($query['category_id']) && !empty($category_id)) { $query['category_id'] = (int) $category_id; } // Filter by subcategory ID if a subcategory archive (all events in a certain subcategory) was requested. $subcategory_id = get_query_var('subcategory_id'); if (empty($query['subcategory_id']) && !empty($subcategory_id)) { $query['subcategory_id'] = (int) $subcategory_id; } // Filter by format ID if a format archive (all events in a certain format) was requested. $format_id = get_query_var('format_id'); if (empty($query['format_id']) && !empty($format_id)) { $query['format_id'] = (int) $format_id; } return $query; }
function ktz_mustread_content() { global $post; if (ot_get_option('ktz_popup_activated') == 'yes') { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'post', 'orderby' => 'rand', 'order' => 'desc', 'showposts' => 3, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $ktz_topfeatquery = new WP_Query($args); if ($ktz_topfeatquery->have_posts()) { echo '<div id="ktz_slidebox">'; echo '<strong class="mustread_title">' . __('Must read', ktz_theme_textdomain) . '</strong><a href="#" class="close">×</a>'; echo '<ul class="mustread_list">'; while ($ktz_topfeatquery->have_posts()) { $ktz_topfeatquery->the_post(); echo '<li class="mustread_li clearfix">'; echo '<div class="pull-left">'; echo ktz_featured_img(50, 50); echo '</div>'; echo '<div class="title">'; echo ktz_posted_title_a(); echo '</div>'; echo '</li>'; } echo '</ul>'; echo '</div>'; } wp_reset_query(); } }
function roots_search_query($escaped = true) { $query = apply_filters('roots_search_query', get_query_var('s')); if ($escaped) { $query = esc_attr($query); } return urldecode($query); }
function bg_welcome_message() { if (!is_front_page() || get_query_var('paged') >= 2) { return; } genesis_widget_area('welcome-message', array('before' => '<div class="welcome-message"><div class="wrap">', 'after' => '</div></div>')); }
/** * Initialize class * @param array $args Query arguments. * @access public * @since 2.0 */ public function __construct($args = array()) { global $answers; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false); $args['post_status'][] = 'publish'; $args['post_status'][] = 'closed'; $this->args = wp_parse_args($args, $defaults); if (isset($this->args['question_id'])) { $question_id = $this->args['question_id']; } if (!empty($question_id)) { $this->args['post_parent'] = $question_id; } if (isset($this->args['sortby'])) { $this->orderby_answers(); } // Check if requesting only for best Answer if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) { $this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1')); } $this->args['post_type'] = 'answer'; $args = $this->args; /** * Initialize parent class */ parent::__construct($args); }
/** * returns the language based on the queried content * * @since 1.2 * * @return object|bool detected language, false if none was found */ protected function get_language_from_content() { // no language set for 404 if (is_404() || is_attachment() && !$this->options['media_support']) { return $this->get_preferred_language(); } if ($var = get_query_var('lang')) { $lang = explode(',', $var); $lang = $this->model->get_language(reset($lang)); // choose the first queried language } elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) { $lang = $this->model->post->get_language($var); } else { foreach ($this->model->get_translated_taxonomies() as $taxonomy) { if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) { $lang = $this->model->term->get_language($var, $taxonomy); } } } /** * Filter the language before it is set from the content * * @since 0.9 * * @param bool|object $lang language object or false if none was found */ return apply_filters('pll_get_current_language', isset($lang) ? $lang : false); }
function novavideo_lite_paginate() { $big = 999999999; // need an unlikely integer global $wp_query; echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages)); }
/** * Get Users Purchases * * Retrieves a list of all purchases by a specific user. * * @access public * @since 1.0 * @param int|string $user User ID or email address * @param int $number Number of purchases to retrieve * * @return array List of all user purchases */ function edd_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { if (empty($user)) { $user = get_current_user_id(); } $status = $status === 'complete' ? 'publish' : $status; $mode = edd_is_test_mode() ? 'test' : 'live'; if ($pagination) { if (get_query_var('paged')) { $paged = get_query_var('paged'); } else { if (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } } } $args = apply_filters('edd_get_users_purchases_args', array('mode' => $mode, 'user' => $user, 'number' => $number, 'status' => $status)); if ($pagination) { $args['page'] = $paged; } else { $args['nopaging'] = true; } $purchases = edd_get_payments($args); // No purchases if (!$purchases) { return false; } return $purchases; }
public function filter_the_content($content) { $ww_problem = false; if (is_page('webwork')) { $ww_problem = true; } else { $ww_problem = get_query_var('ww_problem'); } if ($ww_problem) { $content = '<div id="webwork-app"></div>'; wp_enqueue_script('webwork-app', plugins_url() . '/webwork/build/index.js'); $route_base = get_option('home'); $route_base = preg_replace('|https?://[^/]+/|', '', $route_base); // @todo Centralize this logic. $main_site_url = get_blog_option(1, 'home'); $rest_api_endpoint = trailingslashit($main_site_url) . 'wp-json/webwork/v1/'; // @todo Abstract. $post_data = null; $ww_problem_text = ''; if (!empty($_GET['post_data_key'])) { $post_data = get_blog_option(1, $_GET['post_data_key']); $ww_problem_text = base64_decode($post_data['pg_object']); } // @todo This is awful. $clients = get_blog_option(1, 'webwork_clients'); $remote_course_url = array_search(get_current_blog_id(), $clients); wp_localize_script('webwork-app', 'WWData', array('problem_id' => $ww_problem, 'problem_text' => $ww_problem_text, 'remote_course_url' => $remote_course_url, 'rest_api_nonce' => wp_create_nonce('wp_rest'), 'rest_api_endpoint' => $rest_api_endpoint, 'route_base' => trailingslashit($route_base) . 'webwork/', 'user_can_ask_question' => is_user_logged_in(), 'user_can_post_response' => is_user_logged_in(), 'user_can_vote' => is_user_logged_in())); wp_enqueue_style('webwork-app', plugins_url() . '/webwork/assets/css/app.css'); wp_register_script('webwork-mathjax-loader', WEBWORK_PLUGIN_URL . '/assets/js/webwork-mathjax-loader.js'); $webwork_mathjax_loader_strings = array('mathjax_src' => esc_url('https://cdn.mathjax.org/mathjax/latest/unpacked/MathJax.js?config=TeX-MML-AM_HTMLorMML-full')); wp_localize_script('webwork-mathjax-loader', 'WeBWorK_MathJax', $webwork_mathjax_loader_strings); wp_enqueue_script('webwork-mathjax-loader'); } return $content; }
/** * Hook into the query parsing to detect oEmbed requests. * * If an oEmbed request is made, trigger the output. * * @since 4.4.0 * * @param WP_Query $wp_query The WP_Query instance (passed by reference). */ public function parse_query($wp_query) { if (false === $wp_query->get('oembed', false)) { return; } if (false === $wp_query->get('url', false)) { status_header(400); echo 'URL parameter missing'; exit; } $url = esc_url_raw(get_query_var('url')); $format = wp_oembed_ensure_format(get_query_var('format')); /** * Filter the maxwidth oEmbed parameter. * * @since 4.4.0 * * @param int $maxwidth Maximum allowed width. Default 600. */ $maxwidth = apply_filters('oembed_default_width', 600); $maxwidth = absint(get_query_var('maxwidth', $maxwidth)); $callback = get_query_var('_jsonp', false); $request = array('url' => $url, 'format' => $format, 'maxwidth' => $maxwidth, 'callback' => $callback); echo $this->dispatch($request); exit; }
function html() { $email_id = get_query_var('spemail'); global $post; if (is_object($this->data()) && $this->data()->id) { $email_id = $this->data()->id; } if (isset($_GET['eid'])) { $email_id = SPNL()->validate->int(base64_decode($_GET['eid'])); } // If there's a subscriber ID in the URL, we need to get the subscriber object from it to use for the str_replace below. if (isset($_GET['sid'])) { $subscriber_id = SPNL()->validate->int(base64_decode($_GET['sid'])); } else { $subscriber_id = 0; } //$post = get_post($email_id); $inline = false; if (isset($_GET['inline'])) { $inline = true; } SendPress_Email_Cache::build_cache_for_email($email_id); $message = new SendPress_Email(); $message->id($email_id); $message->subscriber_id($subscriber_id); $message->list_id(0); $body = $message->html(); //print_r( $body ); unset($message); echo $body; //echo SendPress_Template::get_instance()->render_html(false, true, $inline ); }
/** * Get/set $paged * * For use in templates that can be used as static front page. * get_query_var( 'paged' ) returns nothing on front page, but get_query_var( 'page' ) does. * This returns and sets globally $paged so that the query and pagination work. * * @since 0.9 * @global int $paged * @return int Current page number */ function ctfw_page_num() { global $paged; // Use paged if given; otherwise page; otherwise 1 $paged = get_query_var('paged') ? get_query_var('paged') : (get_query_var('page') ? get_query_var('page') : 1); return apply_filters('ctfw_page_num', $paged); }
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } ?> <form id="ap-search-form" class="ap-search-form" action="<?php echo ap_get_link_to('search'); ?> " method="GET"> <div class="ap-qaf-inner"> <input class="form-control" type="text" name="ap_s" id="ap-quick-ask-input" placeholder="<?php _e('Search questions & answers', 'ap'); ?> " value="<?php echo sanitize_text_field(get_query_var('ap_s')); ?> " autocomplete="off" /> <button type="submit" ><?php _e('Search', 'ap'); ?> </button> </div> </form> <?php echo $args['after_widget']; }
function falcon_pagination() { global $wp_query; $big = 999999999; // need an unlikely integer return '<div class="falcon-pagination-wrapper">' . paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages)) . '</div>'; }
function is_exit() { if (is_admin() || is_feed() || is_preview() || 1 === intval(get_query_var('print')) || 1 === intval(get_query_var('printpage')) || false !== strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini')) { return true; } return false; }
/** * Display navigation to next/previous set of posts when applicable. */ function wpmaterialdesign_paging_nav() { // Don't print empty markup if there's only one page. if ($GLOBALS['wp_query']->max_num_pages < 2) { return; } ?> <nav class="navigation paging-navigation" role="navigation"> <?php global $wp_query; $big = 999999999; // need an unlikely integer $pages = paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'type' => 'array')); if (is_array($pages)) { $paged = get_query_var('paged') == 0 ? 1 : get_query_var('paged'); echo '<div class="pagination-wrap"><ul class="pagination">'; foreach ($pages as $page) { echo "<li>{$page}</li>"; } echo '</ul></div>'; } ?> <!-- .nav-links --> </nav><!-- .navigation --> <?php }
function zp_custom_blog_page() { global $post, $paged; $include = genesis_get_option('blog_cat'); $exclude = genesis_get_option('blog_cat_exclude') ? explode(',', str_replace(' ', '', genesis_get_option('blog_cat_exclude'))) : ''; if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } //* Arguments $args = array('cat' => $include, 'category__not_in' => $exclude, 'posts_per_page' => genesis_get_option('blog_cat_num'), 'paged' => $paged); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); do_action('genesis_before_entry'); printf('<article %s>', genesis_attr('entry')); // check post format and call template $format = get_post_format(); get_template_part('content', $format); do_action('genesis_after_entry_content'); //do_action( 'genesis_entry_footer' ); echo '</article>'; do_action('genesis_after_entry'); } } //* Genesis navigation genesis_posts_nav(); //* Restore original query wp_reset_query(); }
/** * Pick the correct template to include * @param string $template Path to template * * @return string Path to template */ public static function templateChooser($template) { $events = TribeEvents::instance(); do_action('tribe_tec_template_chooser', $template); // hijack this method right up front if it's a 404 if (is_404() && $events->displaying == 'single-event' && apply_filters('tribe_events_templates_is_404', '__return_true')) { return get_404_template(); } // no non-events need apply if (!in_array(get_query_var('post_type'), array(TribeEvents::POSTTYPE, TribeEvents::VENUE_POST_TYPE, TribeEvents::ORGANIZER_POST_TYPE)) && !is_tax(TribeEvents::TAXONOMY)) { return $template; } if (tribe_get_option('tribeEventsTemplate', 'default') == '') { return self::getTemplateHierarchy('default-template'); } else { // add_filter( 'wp_title', array(__CLASS__, 'remove_default_title'), 1); if (!is_single() || !post_password_required()) { add_action('loop_start', array(__CLASS__, 'setup_ecp_template')); } $template = locate_template(tribe_get_option('tribeEventsTemplate', 'default') == 'default' ? 'page.php' : tribe_get_option('tribeEventsTemplate', 'default')); if ($template == '') { $template = get_index_template(); } // remove singular body class if sidebar-page.php if ($template == get_stylesheet_directory() . '/sidebar-page.php') { add_filter('body_class', array(__CLASS__, 'remove_singular_body_class')); } else { add_filter('body_class', array(__CLASS__, 'add_singular_body_class')); } return $template; } }
/** * tarski_posts_nav_link() - Outputs next / previous index page links. * * @since 1.2 * @global object $wp_query * @return string */ function tarski_posts_nav_link() { if (get_tarski_option('use_pages')) { global $wp_query; if (!is_singular()) { $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var('paged'); $sep = ' § '; // Only have sep if there's both prev and next results if ($paged < 2 || $paged >= $max_num_pages) { $sep = ''; } if ($max_num_pages > 1) { echo '<p class="pagination">'; if (is_search()) { previous_posts_link('« ' . __('Previous results', 'tarski')); echo $sep; next_posts_link(__('More results', 'tarski') . ' »'); } else { next_posts_link('« ' . __('Older entries', 'tarski')); echo $sep; previous_posts_link(__('Newer entries', 'tarski') . ' »'); } echo "</p>\n"; } } } }
/** * Determines if the current page is /ngg_tag/{*} * * @param $posts Wordpress post objects * @return array Wordpress post objects */ function detect_ngg_tag($posts, $wp_query_local) { global $wp; global $wp_query; $wp_query_orig = false; if ($wp_query_local != null && $wp_query_local != $wp_query) { $wp_query_orig = $wp_query; $wp_query = $wp_query_local; } // This appears to be necessary for multisite installations, but I can't imagine why. More hackery.. $tag = get_query_var('ngg_tag') ? get_query_var('ngg_tag') : get_query_var('name'); if (!$this->ngg_tag_detection_has_run && !is_admin() && !empty($tag) && (stripos($wp->request, 'ngg_tag') === 0 || isset($wp_query->query_vars['page_id']) && $wp_query->query_vars['page_id'] === 'ngg_tag')) { $this->ngg_tag_detection_has_run = TRUE; // Wordpress somewhat-correctly generates several notices, so silence them as they're really unnecessary if (!defined('WP_DEBUG') || !WP_DEBUG) { error_reporting(0); } // create in-code a fake post; we feed it back to Wordpress as the sole result of the "the_posts" filter $posts = NULL; $posts[] = $this->create_ngg_tag_post($tag); $wp_query->is_404 = FALSE; $wp_query->is_page = TRUE; $wp_query->is_singular = TRUE; $wp_query->is_home = FALSE; $wp_query->is_archive = FALSE; $wp_query->is_category = FALSE; unset($wp_query->query['error']); $wp_query->query_vars['error'] = ''; } if ($wp_query_orig !== false) { $wp_query = $wp_query_orig; } return $posts; }