当前位置: 首页>>代码示例>>PHP>>正文


PHP get_post_type_archive_link函数代码示例

本文整理汇总了PHP中get_post_type_archive_link函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_type_archive_link函数的具体用法?PHP get_post_type_archive_link怎么用?PHP get_post_type_archive_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_post_type_archive_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: widget

 /**
  * Outputs the HTML for this widget.
  *
  * @param array  An array of standard parameters for widgets in this theme 
  * @param array  An array of settings for this widget instance 
  * @return void Echoes it's output
  **/
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $count = esc_attr($instance['count']);
     $count = 0 < $count && $count < 10 ? $count : 2;
     $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>'))));
     if ($loop->have_posts()) {
         echo $before_widget;
         if ($instance['title']) {
             echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
         }
         echo '<ul>';
         while ($loop->have_posts()) {
             $loop->the_post();
             global $post;
             $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post);
             if ($read_more) {
                 echo '<li>' . $read_more . '</li>';
             }
         }
         if ($instance['more_text']) {
             echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
 }
开发者ID:forsitemedia,项目名称:events-manager-for-wp,代码行数:36,代码来源:class-em4wp-upcoming-events.php

示例2: profile_questions_loop

 /**
  * User's questions list loop.
  */
 static function profile_questions_loop()
 {
     global $dwqa_options;
     $submit_question_link = get_post_type_archive_link(CMA_AnswerThread::POST_TYPE);
     $questions = get_posts(array('posts_per_page' => -1, 'author' => bp_displayed_user_id(), 'post_type' => CMA_AnswerThread::POST_TYPE));
     include CMA_PATH . '/views/frontend/buddypress/user-questions-loop.phtml';
 }
开发者ID:hemangsk,项目名称:TCB,代码行数:10,代码来源:BuddyPress.php

示例3: wc_template_redirect

/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && sizeof(WC()->cart->get_cart()) == 0 && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(get_permalink(wc_get_page_id('cart')));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(get_permalink(wc_get_page_id('myaccount')))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && $wp_query->found_posts == 1) {
        $product = wc_get_product($wp_query->post);
        if ($product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:34,代码来源:wc-template-functions.php

示例4: widget

 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
开发者ID:pivotlearning,项目名称:wpsite,代码行数:34,代码来源:widget.php

示例5: post_type_link

 function post_type_link($link, $post)
 {
     if ($post->post_type === 'handbook' && $post->post_name === 'handbook') {
         return get_post_type_archive_link('handbook');
     }
     return $link;
 }
开发者ID:serhi,项目名称:wordpress-sites,代码行数:7,代码来源:handbook.php

示例6: woocommerce_shop_page_archive_redirect

/**
 * When default permalinks are enabled, redirect shop page to post type archive url
 **/
function woocommerce_shop_page_archive_redirect()
{
    if (isset($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == get_option('woocommerce_shop_page_id')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    }
}
开发者ID:randyhoyt,项目名称:woocommerce,代码行数:10,代码来源:woocommerce-functions.php

示例7: section_description

    /**
     * The description of the section.
     *
     * @param array $args
     */
    public function section_description($args)
    {
        if (is_array($args) && isset($args['id'])) {
            switch ($args['id']) {
                case 'ib_educator_pages':
                    ?>
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row"><?php 
                    _e('Courses Archive', 'ibeducator');
                    ?>
</th>
								<td>
									<?php 
                    $archive_link = get_post_type_archive_link('ib_educator_course');
                    if ($archive_link) {
                        echo '<a href="' . esc_url($archive_link) . '" target="_blank">' . esc_url($archive_link) . '</a>';
                    }
                    ?>
								</td>
							</tr>
						</tbody>
					</table>
					<?php 
                    break;
            }
        }
    }
开发者ID:zaro,项目名称:ibeducator,代码行数:34,代码来源:General.php

示例8: uls_get_link

/**
 * Return the HTML link of the translation of a post.
 *
 * @param $post_id integer id of post.
 * @param $language string language of translation. If it is null or invalid, current language loaded in the page is used.
 * @param $label string inner text of the link.
 * @param $class string text to include as class parameter in the link
 *
 * @return string the HTML link of the translation link of a post.
 */
function uls_get_link($post_id = null, $language = null, $label = null, $class = 'uls-link')
{
    if ($post_id == null) {
        if (is_home()) {
            $url = get_home_url();
            $translation_url = uls_get_url_translated($url, $language);
        } else {
            if (is_archive()) {
                $url = get_post_type_archive_link(get_post_type());
                $translation_url = uls_get_url_translated($url, $language);
                $title = post_type_archive_title("", false);
            }
        }
    } else {
        $translation_id = uls_get_post_translation_id($post_id, $language);
        if (empty($translation_id)) {
            $translation_id = $post_id;
        }
        //set conversion of permalinks to false
        global $uls_permalink_convertion;
        $uls_permalink_convertion = false;
        $translation_url = uls_get_url_translated(get_permalink($translation_id), $language);
        //set conversion of permalinks to true again
        $uls_permalink_convertion = true;
        $title = get_the_title($translation_id);
    }
    // echo $translation_url;
    if (null == $label) {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $title . '</a>';
    } else {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $label . '</a>';
    }
}
开发者ID:Juni4567,项目名称:mycashflow,代码行数:43,代码来源:uls-functions.php

示例9: sfhiv_draw_taxonomy_query_menu

function sfhiv_draw_taxonomy_query_menu($tax_name, $query, $args = array())
{
    if (!is_object_in_taxonomy($query->query_vars['post_type'], $tax_name)) {
        return;
    }
    if (!isset($args['include'])) {
        $query = sfhiv_remove_url_vars_from_query($query, array($tax_name));
        $query = sfhiv_unpage_query($query);
        $categories = sfhiv_get_taxonomy_in($query, $tax_name, 'ids');
        $args['include'] = implode(",", $categories);
        if (!isset($args['min_display'])) {
            $args['min_display'] = 2;
        }
        if (count($categories) < $args['min_display']) {
            return;
        }
    }
    if (!isset($args['base_link'])) {
        if (is_page() && mini_archive_on_page(get_the_ID())) {
            $args['base_link'] = get_permalink();
        } else {
            $args['base_link'] = get_post_type_archive_link($query->query_vars['post_type']);
        }
    }
    if (!isset($args['title_li'])) {
        $taxonomies = get_taxonomies(array('name' => $tax_name), 'objects');
        foreach ($taxonomies as $taxonomy) {
            $args['title_li'] = $taxonomy->label;
        }
    }
    $args = array_merge(array('taxonomy' => $tax_name, 'show_all_link' => true), $args);
    sfhiv_draw_taxonomy_menu($args);
}
开发者ID:nickdotreid,项目名称:SFHIV-Wordpress-Theme,代码行数:33,代码来源:menu_wrapper.php

示例10: term_link

 public function term_link($link, $term, $taxonomy)
 {
     $facets = FWP()->helper->get_facets();
     $taxes = $sources = array();
     $permalink = FWP()->helper->get_setting('term_permalink', 'slug');
     $permalink_type = FWP()->helper->get_setting('permalink_type', 'get');
     $term = 'term_id' == $permalink ? $term->term_id : $term->slug;
     if (empty($facets)) {
         return $link;
     }
     foreach ($facets as $facet) {
         if (isset($facet['source'])) {
             $sources[$facet['name']] = $facet['source'];
         }
     }
     if (empty($sources)) {
         return $link;
     }
     foreach ($sources as $name => $source) {
         $source = str_replace('tax/', '', $source);
         if ($taxonomy == $source) {
             $post_type = get_post_type_archive_link('job_listing');
             if ('get' == $permalink_type) {
                 $url = add_query_arg('fwp_' . $name, $term, $post_type);
             } else {
                 $url = $post_type . '#!/' . $name . '=' . $term;
             }
             return esc_url($url);
         }
     }
     return $link;
 }
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:32,代码来源:class-facetwp-template.php

示例11: widget

 function widget($args, $instance)
 {
     $out = $args['before_widget'];
     // And here do whatever you want
     $out .= $args['before_title'];
     $out .= $instance['title'];
     $out .= $args['after_title'];
     global $wpdb;
     $count_col = '';
     if ((bool) $instance['show_counts']) {
         $count_col = ", count( substring( TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) ), 1, 1) ) as counts";
     }
     $querystr = "SELECT DISTINCT substring( TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) ), 1, 1) as initial" . $count_col . " FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_type = 'glossary' GROUP BY initial ORDER BY TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) );";
     $pt_initials = $wpdb->get_results($querystr, ARRAY_A);
     $initial_arr = array();
     $base_url = get_post_type_archive_link('glossary');
     if (!$base_url) {
         $base_url = esc_url(home_url('/'));
         if (get_option('show_on_front') == 'page') {
             $base_url = esc_url(get_permalink(get_option('page_for_posts')));
         }
     }
     foreach ($pt_initials as $pt_rec) {
         $link = add_query_arg('az', $pt_rec['initial'], $base_url);
         $item = '<li><a href="' . $link . '">' . $pt_rec['initial'] . '</a></li>';
         if ((bool) $instance['show_counts']) {
             $item = '<li class="count"><a href="' . $link . '">' . $pt_rec['initial'] . ' <span>(' . $pt_rec['counts'] . ')</span>' . '</a></li>';
         }
         $initial_arr[] = $item;
     }
     $out .= '<ul>' . implode('', $initial_arr) . '</ul>';
     $out .= $args['after_widget'];
     echo $out;
 }
开发者ID:CodeAtCode,项目名称:Glossary,代码行数:34,代码来源:a2z.php

示例12: getReferer

 public static function getReferer()
 {
     global $wp_query;
     $isEditPage = function ($url) {
         return false;
     };
     $isTheSameHost = function ($a, $b) {
         return parse_url($a, PHP_URL_HOST) == parse_url($b, PHP_URL_HOST);
     };
     $canUseReferer = (!empty($_SERVER['HTTP_REFERER']) and $isTheSameHost($_SERVER['HTTP_REFERER'], site_url()) and !$isEditPage($_SERVER['HTTP_REFERER']));
     $canUseCurrentPost = (is_single() and !empty($wp_query->post) and $wp_query->post->post_type == CMA_Thread::POST_TYPE and $isEditPage($_GET));
     if (!empty($_GET['backlink'])) {
         // GET backlink param
         return base64_decode(urldecode($_GET['backlink']));
     } else {
         if (!empty($_POST['backlink'])) {
             // POST backlink param
             return $_POST['backlink'];
         } else {
             if ($canUseReferer) {
                 // HTTP referer
                 return $_SERVER['HTTP_REFERER'];
             } else {
                 if ($canUseCurrentPost) {
                     // Question permalink
                     return get_permalink($wp_query->post->ID);
                 } else {
                     // CMA index page
                     return get_post_type_archive_link(CMA_Thread::POST_TYPE);
                 }
             }
         }
     }
 }
开发者ID:hemangsk,项目名称:TCB,代码行数:34,代码来源:CMA.php

示例13: registerPostType

 /**
  * Registering a post type
  *
  * @param string $type slug of the type
  * @param string $singular singular name
  * @param string $plural plural name
  * @param array $config can override the defaults of this function (array_merge)
  */
 public static function registerPostType($type, $singular, $plural, $config = array())
 {
     $labels = array('name' => $plural, 'singular_name' => $singular, 'add_new' => 'Erstellen', 'add_new_item' => $singular . ' erfassen', 'edit_item' => 'Bearbeite ' . $singular, 'new_item' => 'Neues ' . $singular, 'view_item' => $singular . ' ansehen', 'search_items' => $singular . ' suchen', 'not_found' => 'Keine ' . $plural . ' gefunden', 'not_found_in_trash' => 'Keine ' . $plural . ' im Papierkorb gefunden', 'parent_item_colon' => '');
     $defaults = array('labels' => $labels, 'public' => true, 'has_archive' => true, 'plural_view_adminbar' => false);
     $arguments = array_merge_recursive_distinct($defaults, $config);
     if (isset($arguments['plural_view_adminbar']) && $arguments['plural_view_adminbar']) {
         add_action('admin_bar_menu', function ($wp_admin_bar) use($type, $arguments) {
             $object = get_queried_object();
             if ($object->name == $type) {
                 $title = $object->labels->menu_name;
                 if (is_admin()) {
                     $url = get_post_type_archive_link($type);
                 } else {
                     $url = get_admin_url(null, 'edit.php?post_type=' . $type);
                 }
             }
             if ($object->post_type == $type) {
                 if (!is_admin()) {
                     $url = get_edit_post_link($object->ID);
                     $title = $arguments['labels']['edit_item'];
                 }
             }
             // Add admin bar entry
             if ($url) {
                 $wp_admin_bar->add_node(array('id' => 'custom-button', 'title' => $title, 'href' => $url));
             }
         }, 95);
     }
     register_post_type($type, $arguments);
 }
开发者ID:blogwerk,项目名称:oop-theme-plugin,代码行数:38,代码来源:WordPress.php

示例14: getArchiveUrl

 public static function getArchiveUrl()
 {
     $url = get_post_type_archive_link((new static())->post_type);
     if (Filter::isUrl($url)) {
         return $url;
     }
 }
开发者ID:expresser,项目名称:posttype,代码行数:7,代码来源:Archive.php

示例15: woocommerce_redirects

/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works
 **/
function woocommerce_redirects()
{
    global $woocommerce, $wp_query;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (isset($_GET['page_id']) && $_GET['page_id'] > 0 && get_option('permalink_structure') == "" && $_GET['page_id'] == woocommerce_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    }
    // When on the checkout with an empty cart, redirect to cart page
    if (is_page(woocommerce_get_page_id('checkout')) && sizeof($woocommerce->cart->get_cart()) == 0) {
        wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
        exit;
    }
    // When on pay page with no query string, redirect to checkout
    if (is_page(woocommerce_get_page_id('pay')) && !isset($_GET['order'])) {
        wp_redirect(get_permalink(woocommerce_get_page_id('checkout')));
        exit;
    }
    // My account page redirects (logged out)
    if (!is_user_logged_in() && (is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')))) {
        wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
    // Redirect to the product page if we have a single product
    if (is_search() && is_post_type_archive('product') && get_option('woocommerce_redirect_on_single_search_result') == 'yes') {
        if ($wp_query->post_count == 1) {
            $product = new WC_Product($wp_query->post->ID);
            if ($product->is_visible()) {
                wp_safe_redirect(get_permalink($product->id), 302);
            }
            exit;
        }
    }
}
开发者ID:eddiewilson,项目名称:new-ke,代码行数:37,代码来源:woocommerce-functions.php


注:本文中的get_post_type_archive_link函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。