本文整理汇总了PHP中get_term函数的典型用法代码示例。如果您正苦于以下问题:PHP get_term函数的具体用法?PHP get_term怎么用?PHP get_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_term函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_url
/**
* get_url - Returns a url based on a string that holds either post type and id or taxonomy and id
*/
static function get_url($link, $post_id = false)
{
$link = explode(',', $link);
if ($link[0] == 'lightbox') {
$link = wp_get_attachment_image_src($post_id, apply_filters('avf_avia_builder_helper_lightbox_size', 'large'));
return $link[0];
}
if (empty($link[1])) {
return $link[0];
}
if ($link[0] == 'manually') {
return $link[1];
}
if (post_type_exists($link[0])) {
return get_permalink($link[1]);
}
if (taxonomy_exists($link[0])) {
$return = get_term_link(get_term($link[1], $link[0]));
if (is_object($return)) {
$return = "";
}
//if an object is returned it is a WP_Error object and something was not found
return $return;
}
}
开发者ID:erynet,项目名称:SUAWEBv2,代码行数:28,代码来源:generic-helper.class.php
示例2: ctfw_get_posts
/**
* Get posts
*
* This can optionally be used by the template.
* $this->instance is sanitized before being made available here.
*
* @since 0.9
* @return array Posts for widget template
*/
function ctfw_get_posts()
{
// Base arguments
$args = array('post_type' => 'ctc_sermon', 'orderby' => $this->ctfw_instance['orderby'], 'order' => $this->ctfw_instance['order'], 'numberposts' => $this->ctfw_instance['limit'], 'suppress_filters' => false);
// Topic argument
if ('all' != $this->ctfw_instance['topic'] && ($topic_term = get_term($this->ctfw_instance['topic'], 'ctc_sermon_topic'))) {
$args['ctc_sermon_topic'] = $topic_term->slug;
}
// Book argument
if ('all' != $this->ctfw_instance['book'] && ($book_term = get_term($this->ctfw_instance['book'], 'ctc_sermon_book'))) {
$args['ctc_sermon_book'] = $book_term->slug;
}
// Series argument
if ('all' != $this->ctfw_instance['series'] && ($series_term = get_term($this->ctfw_instance['series'], 'ctc_sermon_series'))) {
$args['ctc_sermon_series'] = $series_term->slug;
}
// Speaker argument
if ('all' != $this->ctfw_instance['speaker'] && ($speaker_term = get_term($this->ctfw_instance['speaker'], 'ctc_sermon_speaker'))) {
$args['ctc_sermon_speaker'] = $speaker_term->slug;
}
// Get posts
$posts = get_posts($args);
// Return filtered
return apply_filters('ctfw_sermons_widget_get_posts', $posts);
}
开发者ID:pemiu01,项目名称:church-theme-framework,代码行数:34,代码来源:widget-sermons.php
示例3: dvteamtaxonomy_show_id
function dvteamtaxonomy_show_id($ver, $name, $id)
{
$term = get_term($id, 'dvteamtaxonomy');
$term_id = $term->term_id;
$taxonomy = $term->name;
return 'dvteamtaxonomyid' === $name ? $term_id : $ver;
}
开发者ID:Brandonsmith23,项目名称:prodgyr,代码行数:7,代码来源:ourteam_cpt.php
示例4: hyyan_slider_query
/**
* Build WP_Query object for the given slider
*
* @see Hyyan_Slider_Shortcode::FILTER_SHORTCODE_QueryArgs
*
* @param string $slider slider name
* @param string $order slides order
* @param string $orderBy order slides by ?
*
* @return \WP_Query
* @throws \RuntimeException if the slider does not exist
*/
function hyyan_slider_query($slider, $order = 'DESC', $orderBy = 'rand')
{
$slider = esc_attr((string) $slider);
/** check for term existance */
if (!term_exists($slider, Hyyan_Slider::CUSTOM_TAXONOMY)) {
throw new \RuntimeException(sprintf('Can not build query for %s slider - term does not exist', $slider));
}
if (function_exists('pll_get_term')) {
// get slider object
$term = get_term_by('slug', $slider, Hyyan_Slider::CUSTOM_TAXONOMY);
$slider = $term->slug;
if ($term) {
// find the id of translated slider
$id = pll_get_term($term->term_id);
// get translated slider object
$trans_term = get_term($id, Hyyan_Slider::CUSTOM_TAXONOMY);
if ($trans_term && !$trans_term instanceof WP_Error) {
$slider = $trans_term->slug;
}
}
}
/**
* Query object
*
* @see Hyyan_Slider_Shortcode::FILTER_SHORTCODE_QueryArgs
*
* @var WP_Query
*/
$query = new WP_Query(apply_filters(Hyyan_Slider_Events::FILTER_SHORTCODE_QueryArgs, array('post_type' => Hyyan_Slider::CUSTOM_POST, 'taxonomy' => Hyyan_Slider::CUSTOM_TAXONOMY, 'term' => $slider, 'post_status' => 'publish', 'order' => esc_attr($order), 'orderby' => esc_attr($orderBy), 'posts_per_page' => -1, 'lang' => null)));
return $query;
}
开发者ID:hyyan,项目名称:slider,代码行数:43,代码来源:functions.php
示例5: bdn_browse_docs
function bdn_browse_docs()
{
global $wp_query;
if (is_singular() || is_404() || is_admin()) {
return false;
}
if (empty($wp_query->query_vars['post_type'])) {
$wp_query->query_vars['post_type'] = array('doc');
$wp_query->query_vars['orderby'] = 'modified';
}
if (is_home() && !isset($_GET['all']) && ($default_view = get_user_meta(get_current_user_id(), 'default_view', true))) {
if ($default_view == 'default_desk') {
$default_desk = (int) get_user_meta(get_current_user_id(), 'default_desk', true);
$term = get_term($default_desk, 'desk');
if (!empty($term) && !is_wp_error($term)) {
$wp_query->query_vars['desk'] = $term->slug;
}
} elseif ($default_view == 'user_docs') {
$user = wp_get_current_user();
$wp_query->query_vars['author_name'] = $user->user_login;
}
}
if (!empty($_GET['hide-final-published'])) {
$wp_query->query_vars['tax_query'][] = array('taxonomy' => 'status', 'field' => 'slug', 'terms' => array('final-published'), 'operator' => 'NOT IN');
}
}
开发者ID:bangordailynews,项目名称:Newsroom-Tools,代码行数:26,代码来源:init.php
示例6: manage_rank_column
public function manage_rank_column($display, $column, $term_id)
{
if ('users' === $column) {
$term = get_term($term_id, 'rank');
echo $term->count ? $term->count : 0;
}
}
开发者ID:jessor,项目名称:anspress,代码行数:7,代码来源:anspress-ranks.php
示例7: link_cat_row
function link_cat_row($category)
{
global $class;
if (!($category = get_term($category, 'link_category'))) {
return false;
}
if (is_wp_error($category)) {
return $category;
}
$name = $name_override ? $name_override : $category->name;
if (current_user_can('manage_categories')) {
$edit = "<a class='row-title' href='link-category.php?action=edit&cat_ID={$category->term_id}' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "' class='edit'>{$name}</a>";
$default_cat_id = (int) get_option('default_link_category');
} else {
$edit = $name;
}
$class = " class='alternate'" == $class ? '' : " class='alternate'";
$category->count = number_format_i18n($category->count);
$count = $category->count > 0 ? "<a href='link-manager.php?cat_id={$category->term_id}'>{$category->count}</a>" : $category->count;
$output = "<tr id='link-cat-{$category->term_id}'{$class}>\n\t\t\t <th scope='row' class='check-column'>";
if (absint(get_option('default_link_category')) != $category->term_id) {
$output .= "<input type='checkbox' name='delete[]' value='{$category->term_id}' />";
} else {
$output .= " ";
}
$output .= "</th>\n\t\t\t\t<td>{$edit}</td>\n\t\t\t\t<td>{$category->description}</td>\n\t\t\t\t<td class='num'>{$count}</td></tr>";
return apply_filters('link_cat_row', $output);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:28,代码来源:template.php
示例8: mark_posts_misc_functions
/**
* Misc functions
*
* @since 1.0.0
* @updated 1.0.8
*/
function mark_posts_misc_functions()
{
// mark all posts
if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['mark-all-posts-term-id'])) {
$term_id = $_GET['mark-all-posts-term-id'];
/* TODO:: SECURITY */
// set color only for selected post types
$get_mark_posts_settings = get_option('mark_posts_settings');
foreach ($get_mark_posts_settings['mark_posts_posttypes'] as $post_type) {
$args = array('posts_per_page' => -1, 'post_type' => $post_type);
// get all posts
$all_posts = get_posts($args);
foreach ($all_posts as $post) {
// Sanitize the user input.
$mydata = sanitize_text_field($term_id);
$myterm = get_term($term_id, 'marker');
// Update the meta field.
update_post_meta($post->ID, 'mark_posts_term_id', $mydata);
// Update taxonomy count
wp_set_object_terms($post->ID, $myterm->name, 'marker');
}
}
echo mark_posts_display_settings_updated();
}
}
开发者ID:flymke,项目名称:mark-posts,代码行数:31,代码来源:admin.php
示例9: load_apple_news_section
function load_apple_news_section($field)
{
$post = new TimberPost();
$post_cat = $post->get_terms('category')[0];
$post_cat = $post_cat->parent ? get_term($post_cat->parent) : $post_cat;
$api = $this->get_api_instance();
$channel = get_field('apple_news_channel_id', 'option');
$sections_response = $api->get_sections($channel);
if (!isset($sections_response->data)) {
echo "<pre>";
print_r($sections_response);
die;
}
$sections = $sections_response->data;
$choices = array();
foreach ($sections as $section) {
$choices[$section->links->self] = $section->name;
if ($section->name === $post_cat->name) {
$default = $section->id;
}
}
$field['choices'] = $choices;
$field['default_value'] = array(isset($default) ? $default : null);
return $field;
}
开发者ID:shortlist-digital,项目名称:agreable-apple-news-plugin,代码行数:25,代码来源:hooks.php
示例10: __construct
/**
* The constructor.
*
* @param int $id
*/
public function __construct($id = 0)
{
$this->id = papi_get_term_id($id);
$this->term = get_term($this->id, '');
$id = papi_get_taxonomy_type_id($this->id);
$this->type_class = papi_get_entry_type_by_id($id);
}
开发者ID:nlemoine,项目名称:papi,代码行数:12,代码来源:class-papi-term-store.php
示例11: set_sql_query_statement
/**
* Customize the sql query statements.
* Add a join with the current indexing language
*
* @param $sql_statements
*
* @return mixed
*/
function set_sql_query_statement($sql_statements, $parameters)
{
global $wpdb;
// Get the index indexing language
$language = $this->get_solr_index_indexing_language($parameters['index_indice']);
// Get the languages
$languages = $this->get_languages();
// Retrieve the term_id used for this language code
if (!isset($languages[$language]['term_id'])) {
throw new ErrorException(sprintf("The language '%s' is undefined in %s (not in the taxonomy terms).", $language, static::_PLUGIN_NAME_IN_MESSAGES));
}
$language_term_id = $languages[$language]['term_id'];
$term = get_term($language_term_id, 'language');
if (!isset($term)) {
throw new ErrorException(sprintf("The language '%s' term_id '%s' is undefined in %s (not in the taxonomy terms).", $language, $language_term_id, static::_PLUGIN_NAME_IN_MESSAGES));
}
$term_taxonomy_id = $term->term_taxonomy_id;
if (isset($language)) {
// Join statement
$sql_joint_statement = ' JOIN ';
$sql_joint_statement .= $wpdb->prefix . self::TABLE_TERM_RELATION_SHIPS . ' AS ' . 'wp_term_relationships';
$sql_joint_statement .= " ON posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = '%s' ";
$sql_statements['JOIN'] = sprintf($sql_joint_statement, $term_taxonomy_id);
}
return $sql_statements;
}
开发者ID:silvestrelosada,项目名称:wpsolr-search-engine,代码行数:34,代码来源:plugin-polylang.php
示例12: test_the_taxonomy_argument_overrules_the_factory_taxonomy
function test_the_taxonomy_argument_overrules_the_factory_taxonomy()
{
$term_factory = new WP_UnitTest_Factory_For_term(null, 'category');
$id = $term_factory->create(array('taxonomy' => 'post_tag'));
$term = get_term($id, 'post_tag');
$this->assertEquals($id, $term->term_id);
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:7,代码来源:factory.php
示例13: test_valid_term
function test_valid_term()
{
$this->make_user_by_role('editor');
$term = get_term($this->term['term_id'], 'category', ARRAY_A);
$result = $this->myxmlrpcserver->wp_getTerm(array(1, 'editor', 'editor', 'category', $this->term['term_id']));
$this->assertNotInstanceOf('IXR_Error', $result);
$this->assertEquals($result, $term);
// Check DataTypes
$this->assertInternalType('string', $result['name']);
$this->assertInternalType('string', $result['slug']);
$this->assertInternalType('string', $result['taxonomy']);
$this->assertInternalType('string', $result['description']);
$this->assertInternalType('int', $result['count']);
// We expect all ID's to be strings not integers so we don't return something larger than an XMLRPC integer can describe.
$this->assertStringMatchesFormat('%d', $result['term_id']);
$this->assertStringMatchesFormat('%d', $result['term_group']);
$this->assertStringMatchesFormat('%d', $result['term_taxonomy_id']);
$this->assertStringMatchesFormat('%d', $result['parent']);
// Check Data
$this->assertEquals(0, $result['count']);
$this->assertEquals($term['name'], $result['name']);
$this->assertEquals($term['slug'], $result['slug']);
$this->assertEquals('category', $result['taxonomy']);
$this->assertEquals($term['description'], $result['description']);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:25,代码来源:getTerm.php
示例14: ninja_annc_display_group
function ninja_annc_display_group($group_id)
{
$group = get_term($group_id, 'ninja_annc_groups');
$widget = false;
$plugin_settings = get_option('ninja_annc_settings');
$group_settings = $plugin_settings['groups'][$group_id];
if ($group_settings['override'] == 1) {
if ($group_settings['location'] == 'function') {
$num = $group_settings['show_number'];
$order = $group_settings['show_order'];
switch ($order) {
case 'random':
$orderby = 'rand';
$order = '';
break;
case 'date_asc':
$orderby = 'post_date';
$order = 'ASC';
break;
case 'date_desc':
$orderby = 'post_date';
$order = 'DESC';
break;
}
$args = array('numberposts' => $num, 'orderby' => $orderby, 'post_type' => 'ninja_annc', 'tax_query' => array(array('taxonomy' => 'ninja_annc_groups', 'field' => 'slug', 'terms' => $group->slug)));
if ($order != '') {
$args['order'] = $order;
}
$posts_array = get_posts($args);
foreach ($posts_array as $post) {
echo ninja_annc_check($post->ID, $widget, $group->term_id);
}
}
}
}
开发者ID:taeche,项目名称:SoDoEx,代码行数:35,代码来源:display.php
示例15: __construct
public function __construct($menu_term_slug)
{
parent::__construct();
$menu = wp_get_nav_menu_object($menu_term_slug);
if (!empty($menu)) {
$this->menu = $menu;
$nav_menu_items = wp_get_nav_menu_items($this->menu->term_id);
cfd_tmp_dbg('nav_menu_items_raw.txt', $nav_menu_items, 'print');
foreach ($nav_menu_items as $item) {
$menu_item = wp_setup_nav_menu_item($item);
$menu_item->metadata = get_metadata('post', $item->ID);
foreach ($menu_item->metadata as $key => &$value) {
$value[0] = maybe_unserialize($value[0]);
}
if ($menu_item->type == 'post_type') {
$menu_item->parent = get_post($menu_item->metadata['_menu_item_object_id'][0]);
} elseif ($menu_item->type == 'taxonomy' && (!property_exists($menu, 'object') || $menu->object != 'custom')) {
$menu_item->term = get_term($menu_item->metadata['_menu_item_object_id'][0], $menu_item->metadata['_menu_item_object'][0]);
}
$this->items[] = $menu_item;
}
} else {
throw new Exception(__('Invalid menu id', 'cf-deploy') . ': ' . esc_attr($menu_term_slug));
}
}
开发者ID:niko-lgdcom,项目名称:wp-install,代码行数:25,代码来源:menu.class.php
示例16: get_terms_for_site
/**
* Return the terms for the given type.
*
* @param int $site_id Blog ID.
*
* @return array
*/
public function get_terms_for_site($site_id)
{
$out = [];
switch_to_blog($site_id);
$taxonomy_object = get_taxonomy($this->taxonomy_name);
if (!current_user_can($taxonomy_object->cap->edit_terms)) {
$terms = [];
} else {
$terms = get_terms($this->taxonomy_name, ['hide_empty' => FALSE]);
}
foreach ($terms as $term) {
if (is_taxonomy_hierarchical($this->taxonomy_name)) {
$ancestors = get_ancestors($term->term_id, $this->taxonomy_name);
if (!empty($ancestors)) {
foreach ($ancestors as $ancestor) {
$parent_term = get_term($ancestor, $this->taxonomy_name);
$term->name = $parent_term->name . '/' . $term->name;
}
}
}
$out[$term->term_taxonomy_id] = esc_html($term->name);
}
restore_current_blog();
uasort($out, 'strcasecmp');
return $out;
}
开发者ID:inpsyde,项目名称:multilingual-press,代码行数:33,代码来源:Mlp_Term_Translation_Presenter.php
示例17: add_mediatags_alternate_link
function add_mediatags_alternate_link()
{
global $wp_version;
$mediatag_rss_feed = get_option('mediatag_rss_feed', 'yes');
if (!$mediatag_rss_feed || $mediatag_rss_feed != "yes") {
return;
}
$mediatag_var = get_query_var(MEDIA_TAGS_QUERYVAR);
//echo "mediatag_var<pre>"; print_r($mediatag_var); echo "</pre>";
if ($mediatag_var) {
if (version_compare($wp_version, '3.0', '<')) {
$mediatag_term = is_term($mediatag_var, MEDIA_TAGS_TAXONOMY);
} else {
$mediatag_term = term_exists($mediatag_var, MEDIA_TAGS_TAXONOMY);
}
if ($mediatag_term) {
$mediatag_term = get_term($mediatag_term['term_id'], MEDIA_TAGS_TAXONOMY);
$feed_title = get_bloginfo('name') . " » " . __('Media-Tags RSS Feed', MEDIA_TAGS_I18N_DOMAIN) . " » " . $mediatag_term->name;
$feed_link = get_mediatag_link($mediatag_term->term_id, true);
if ($feed_link) {
?>
<link id="MediaTagsRSS" rel="alternate" type="application/rss+xml"
title="<?php
echo $feed_title;
?>
"
href="<?php
echo $feed_link;
?>
" />
<?php
}
}
}
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:35,代码来源:mediatags_feed.php
示例18: get_wp_object
/**
* @return array|null|WP_Error|WP_Term
*/
function get_wp_object()
{
remove_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1);
$term = get_term($this->id, $this->taxonomy, OBJECT);
add_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1, 1);
return $term;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:10,代码来源:class-wpml-term-element.php
示例19: my_add_cat_description
function my_add_cat_description($category)
{
$cat_id = $category->term_id;
$prod_term = get_term($cat_id, 'product_cat');
$description = $prod_term->description;
echo '<div class="shop_cat_desc">' . $description . '</div>';
}
开发者ID:jens-wetzel,项目名称:use2,代码行数:7,代码来源:functions.php
示例20: get_admin_page
public static function get_admin_page()
{
$products = get_term(2, 'product_type');
?>
<div class="wrap">
<h2>Import WooCommerce product attributes from VirtueMart</h2>
<p>Product count: <b><?php
echo $products->count;
?>
pcs</b></p>
<ol>
<li>
<form action="<?php
echo admin_url('admin.php');
?>
">
<input type="hidden" name="page" id="page" value="<?php
echo $_REQUEST['page'];
?>
"/>
<input type="hidden" name="action" id="action" value="import"/>
<p class="submit"><input type="submit" value="Start import" class="button button-primary" id="submit" name="submit"></p>
</form>
</li>
</ol>
</div>
<?php
}
开发者ID:lukasprelovsky,项目名称:wp-plugin,代码行数:28,代码来源:woocommerce-attribute-import.php
注:本文中的get_term函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论