本文整理汇总了PHP中get_cat_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_cat_id函数的具体用法?PHP get_cat_id怎么用?PHP get_cat_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_cat_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: ft_exclude_category_from_home
function ft_exclude_category_from_home($query)
{
$featured = get_cat_id('featured');
if ($query->is_main_query() && $query->is_home()) {
$query->set('cat', '-' . $featured);
}
}
开发者ID:elliebartling,项目名称:genesis-freetogether,代码行数:7,代码来源:functions.php
示例2: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
extract($args);
$title = $instance['title'];
$title = apply_filters('widget_title', empty($instance['title']) ? __('Latest tweets', 'framework') : $instance['title'], $instance, $this->id_base);
$categ_parent = $instance['parent_category'];
$categ_parent_id = get_cat_id(htmlentities($categ_parent));
echo $before_widget;
?>
<?php
echo $before_title . $title . $after_title;
?>
<?php
$categ_args = array('child_of' => $categ_parent_id, 'title_li' => '', 'show_option_none' => __('<p class="textwidget">No child categories that belong to the parent category you\'ve selected were found.</p>', 'framework'));
?>
<ul>
<?php
wp_list_categories($categ_args);
?>
</ul>
<?php
echo $after_widget;
?>
<?php
}
开发者ID:robasaad,项目名称:hadi,代码行数:32,代码来源:widget_blog_cat.php
示例3: myTemplateSelect
function myTemplateSelect()
{
if (is_category() && !is_feed()) {
if (is_category(get_cat_id('projekt')) || cat_is_ancestor_of(get_cat_id('projekt'), get_query_var('cat'))) {
load_template(STYLESHEETPATH . '/category-projekt.php');
exit;
}
}
}
开发者ID:ayond,项目名称:accglas,代码行数:9,代码来源:functions.php
示例4: constantTest
protected function constantTest()
{
$post_id_1 = 0;
$time = microtime(true);
for ($i = 0; $i < $this->runNumber; $i++) {
get_cat_id("Uncategorized");
}
$time = microtime(true) - $time;
$this->enterResult($time);
}
开发者ID:AkimBolushbek,项目名称:wordpress-soc-2007,代码行数:10,代码来源:CategoryFunctions.php
示例5: start_el
function start_el(&$output, $item, $depth, $args)
{
$cur_cat_id = get_cat_id(single_cat_title("", false));
$url = '#' !== $item->url ? $item->url : '';
if (get_category_link($cur_cat_id) == $url) {
$output .= '<option class="active" selected="selected" value="' . $url . '">' . $item->title;
} else {
$output .= '<option value="' . $url . '">' . $item->title;
}
}
开发者ID:bsboby,项目名称:Sample-code-frontend-dev,代码行数:10,代码来源:category.php
示例6: render
public function render()
{
/* @var $post \WP_Post */
global $post;
$this->entries = array();
$this->addHomePage();
if (!is_front_page() && is_home()) {
$show_on_front = get_option('show_on_front');
if ($show_on_front == 'page') {
$this->addBlogPage();
}
} elseif (is_tag()) {
$this->addBlogPage();
$tag_id = get_query_var('tag_id');
$this->addTag($tag_id);
} elseif (is_category()) {
$this->addBlogPage();
$cat_id = get_cat_id(single_cat_title('', false));
$this->addCategory($cat_id);
} elseif (is_author()) {
$this->addAuthor(get_the_author_meta('ID'));
} elseif (is_search()) {
$this->addSearch(get_search_query());
} elseif (is_page()) {
$this->addPage($post->ID);
} elseif (is_single()) {
$this->addBlogPage();
$categories = get_the_category();
if (isset($categories[0])) {
$this->addCategory($categories[0]->cat_ID);
}
$this->addPost($post->ID);
} elseif (is_401()) {
$this->addErrorPage(401);
} elseif (is_403()) {
$this->addErrorPage(403);
} elseif (is_404()) {
$this->addErrorPage();
} elseif (is_tax()) {
$this->addBlogPage();
$term = get_query_var('term');
$tax = get_query_var('taxonomy');
if ($tax == 'post_format') {
$this->addPostFormat($term);
}
} elseif (is_archive()) {
$this->addBlogPage();
$this->addDate(is_year() || is_month() || is_day() ? get_the_time('Y') : false, is_year() || is_month() ? get_the_time('m') : false, is_day() ? get_the_time('d') : false);
}
return $this->entries;
}
开发者ID:e-picas,项目名称:wp-basic-bootstrap,代码行数:51,代码来源:WP_Basic_Bootstrap_Breadcrumb.php
示例7: create_story
function create_story($param)
{
//the new post object
$post = array('post_status' => 'draft', 'post_author' => $param['author'], 'post_category' => array((int) get_cat_id('histoire')));
if ($param['content']) {
$post['post_content'] = $param['content'];
}
if ($param['title']) {
$post['post_title'] = wp_strip_all_tags($param['title']);
}
//insert the post in db
$post_id = wp_insert_post($post, true);
//updates localisation custom field
if ($param['localisation']) {
update_field("field_5654eb30ea15e", $param['localisation'], $post_id);
}
if ($param['tags']) {
wp_set_post_tags($post_id, $param['tags']);
}
return formatted_post(get_post($post_id));
}
开发者ID:tristanhamel,项目名称:cehavre,代码行数:21,代码来源:karine-theme-rest.php
示例8: esc_url
}
?>
</div>
<a href="<?php
echo esc_url(home_url('/'));
?>
wp-admin" class="btn-large waves-effect waves-light blue darken-4">Login to the Wordpress Dashboard</a>
</div>
<div class="col m12 l4">
<div class="icon-block">
<h5 class="center">Learning Calendar and Staff Events</h5>
<!--<?php
$category_id = get_cat_id('Staff Events');
echo $category_id;
?>
-->
<ul class="collection">
<?php
query_posts('cat=140,141&showposts=5');
?>
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<li><a href="<?php
the_permalink();
?>
开发者ID:rallisonr,项目名称:uva-staff-theme,代码行数:31,代码来源:front-page.php
示例9: intval
$goods_id = intval(pq('input[name="id"]')->attr('value'));
// 说明源id大于47900是无水印的 http://www.tomdurrie.com/search.php?page=380 前判读吧..
// 63767 后面开始进行第二次采集
if ($goods_id > 63767) {
// 删除旧产品数据和相册数据
delete('ecs_goods', array('goods_id' => $goods_id));
delete('ecs_goods_gallery', array('goods_id' => $goods_id));
$cat_name = trim(pq('#ur_here>.f_l>a:eq(1)')->html());
$brand_name = trim(pq('.props>dl:eq(1)>dd')->html());
$price_tmp = trim(pq('#ECS_SHOPPRICE')->html());
if (preg_match('(\\d+)', $price_tmp, $match)) {
$price = $match[0];
} else {
$price = 0;
}
$goods_info = array('goods_id' => $goods_id, 'cat_id' => get_cat_id($cat_name), 'goods_sn' => trim(pq('.props>dl:eq(0)>dd')->html()), 'goods_name' => trim(pq('h1')->html()), 'goods_desc' => '<table>' . pq('div>table')->html() . '</table>', 'brand_id' => get_brand_id($brand_name), 'goods_number' => 9999, 'market_price' => (int) floor($price / 0.57), 'shop_price' => $price, 'goods_thumb' => 'http://baobaopic.qiniudn.com/' . $v['thumb_img_org']);
$result = insert('ecs_goods', $goods_info);
/**
* 获取相册
*
*/
$gallerys_tmp = pq('.gallery>#demo>#demo1>ul>li');
$goods_gallerys = array();
foreach ($gallerys_tmp as $li) {
$img_url = trim(pq($li)->find('a')->attr('rev'));
$thumb_url = trim(pq($li)->find('img')->attr('src'));
$goods_gallerys[] = array('goods_id' => $goods_id, 'img_url' => !empty($img_url) ? 'http://baobaopic.qiniudn.com/' . $img_url : '', 'thumb_url' => !empty($thumb_url) ? 'http://baobaopic.qiniudn.com/' . $thumb_url : '');
}
if (isset($goods_gallerys[0]['img_url']) && !empty($goods_gallerys[0]['img_url'])) {
$gallery_result = insert_batch('ecs_goods_gallery', $goods_gallerys);
}
开发者ID:boxcore,项目名称:xspider,代码行数:31,代码来源:get-ecshop-string.shell.php
示例10: attribute_escape
</div>
<!-- <div class="new_add_archives_and_categories">
<div class="ForumBox SelectBox">
<h2>Archives</h2>
<?php
// wp_get_archives('type=monthly');
?>
<select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=\"\"><?php
echo attribute_escape(__('Select Month'));
?>
</option>
<?php
wp_get_archives('type=monthly&format=option&cat=' . get_cat_id('Events'));
?>
</select><br/><br/><br/>
<h2>Categories</h2>
<select>
<option>Select Categories</option>
</select>
</div>
</div> -->
</div>
<!-- END OF RIGHTCOL -->
<div class="clear"><!-- DON'T DELETE --></div>
开发者ID:juslee,项目名称:e27,代码行数:30,代码来源:single_ORIG.php
示例11: get_the_tags
$tags = get_the_tags($post->ID);
foreach ($tags as $tag) {
$key .= $tag->name . ', ';
}
if ($key != "") {
$keywords = $key;
}
}
} else {
if (is_archive()) {
if (is_tag()) {
$meta_title = $title = 'Tags' . ' | ' . $meta_title;
$description_content = preg_replace("/&#?[a-z0-9]+;/i", "", tag_description($tag->term_id));
} else {
$meta_title = $title = preg_replace("/&#?[a-z0-9]+;/i", "", $meta_title);
$cat_id = get_cat_id(single_cat_title('', false));
$description_content = preg_replace("/&#?[a-z0-9]+;/i", "", category_description($cat_id));
}
}
}
}
?>
<title><?php
echo esc_html($meta_title);
?>
</title>
<meta name="description" content="<?php
echo esc_attr(trim(strip_tags($description_content)));
?>
">
<meta name="keywords" content="<?php
开发者ID:Didox,项目名称:beminfinito,代码行数:31,代码来源:meta.php
示例12: elseif
} elseif (in_category(144)) {
echo 'rocio';
}
if (in_category($espera)) {
echo ' espera';
}
?>
" id="post-<?php
the_ID();
?>
">
<?php
// Show the new category images
foreach (get_the_category() as $category) {
$proyectos = get_option('bach_projects');
$proyecto = get_cat_id($proyectos);
if (get_root_category($category) == $proyecto) {
echo '<a href="' . get_bloginfo('url') . '/category/' . $category->slug . '"><img src="' . trim(ereg_replace("</p>", "", category_description($category->cat_ID)), "<p>") . '" alt="' . $category->cat_name . '" class="logo" height="48px" width="48px" style="float:right;" /><a>';
}
}
?>
<h3 class="titulillo"><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a></h3>
<div align="center"><?php
include TEMPLATEPATH . '/clases.php';
开发者ID:bi0xid,项目名称:bach-theme,代码行数:31,代码来源:archive.php
示例13: myprefix_query_offset
function myprefix_query_offset(&$query)
{
/* don't show in focus posts on homepage */
if ($query->is_home()) {
$trending_cat_id = get_cat_id('Compass');
$guidebook_cat_id = get_cat_id('Guidebook');
$tax_query = array(array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => [$trending_cat_id, $guidebook_cat_id], 'operator' => 'NOT IN'));
$query->set('tax_query', $tax_query);
}
if (!($query->is_home() && $query->is_main_query())) {
return;
}
$ppp = get_option('posts_per_page');
if (is_paged()) {
$offset = -1 * ($ppp - get_option('homepage_post_count'));
$sticky_posts = get_option('sticky_posts');
$numStickies = 0;
if (is_array($sticky_posts)) {
$numStickies = sizeof($sticky_posts);
$offset = $offset - $numStickies;
}
//note ... if we make more posts sticky than can take up a whole page, we'd have an issue.
//not worrying about that edge case as it's not feasible.
$page_offset = $offset + (get_query_var('paged') - 1) * $ppp;
$query->set('offset', $page_offset);
} else {
//we handle the custom logic for the first page in index.php - so nothing to do in this clause
}
}
开发者ID:BBGInnovate,项目名称:rizeWP,代码行数:29,代码来源:functions.php
示例14: get_option
<?php
$prioridades = get_option('bach_priorities');
$priorities = get_cat_id($prioridades);
$proyectos = get_option('bach_projects');
$projects = get_cat_id($proyectos);
$usuarios = get_option('bach_users');
$users = get_cat_id($usuarios);
$abierto = get_option('bach_open');
$open = get_cat_id($abierto);
$padre = $wpdb->get_var("SELECT parent from $wpdb->term_taxonomy WHERE term_id = '$open'");
?>
<div id="sidebar">
<div style="float:left;"><?php include (TEMPLATEPATH . '/searchform.php'); ?></div>
<ul>
<?php
if( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) {
$before = "<li><h2>Proyectos recientes</h2>\n";
$after = "</li>\n";
$num_to_show = 35;
echo prologue_recent_projects( $num_to_show, $before, $after );
} // if dynamic_sidebar
?>
</ul>
<?
开发者ID:bi0xid,项目名称:bach-theme,代码行数:30,代码来源:sidebar.php
示例15: get_header
<?php get_header();?>
<?php $catid = get_cat_id( single_cat_title("",false) );?>
<head><title>Search result for <?php echo '"' . $_GET['s'] . '"' . ' - '; bloginfo('name'); ?></title></head>
<div class="container contain-content">
<?php get_search_form();?>
<div class="shadow-box shadow-box-colour"><h6>Search Result for : <?php echo $_GET['s'];?></h6></div>
<?php if (have_posts()) : while(have_posts()) : the_post();?>
<div class="shadow-box-page shadow-box-colour">
<a class = 'header-link' href="<?php the_permalink();?>" title = "<?php the_title();?>"><h3 class = "header-text text-center"><?php the_title();?></h3></a>
<center><?php if (has_post_thumbnail()) {the_post_thumbnail('large',array('class' => 'img-responsive img-thumb'));} ?></center>
<p class = "content"><?php the_excerpt(); ?></p>
</div>
<?php endwhile; else : ?>
<div class="shadow-box-page shadow-box-colour block-center">
<center>
<h4 style = "margin-top:5px;">We can't found what you are looking for.</h4>
<p class= "text-muted">Try other keyword or <a href="<?php echo get_option('home');?>">Go Home?</a></p>
</center>
</div> <?php endif; ?>
</div>
<script async src = "<?php echo get_template_directory_uri(); ?>/js/all.min.js"></script>
开发者ID:arnondora,项目名称:wordpress-paper-theme,代码行数:26,代码来源:search.php
示例16: array
<a href="<?php
echo $categoryLink;
?>
" style="display: block; clear: left;">Read more <?php
echo $teamCategory->name;
?>
posts »</a>
<?php
}
?>
</section>
<?php
$qParams = array('post_type' => array('post'), 'posts_per_page' => $numPortfolioPostsToShow, 'category__and' => [$teamCategoryID, get_cat_id('Project')]);
query_posts($qParams);
$numProjectsAvailable = $wp_query->found_posts;
if (have_posts()) {
?>
<section class="usa-section usa-grid">
<h6 class="bbg-label small"><a href="<?php
echo $teamPortfolioLink;
?>
"><?php
echo $teamCategory->name;
?>
projects</a></h6>
<div class="bbg-grid__container">
开发者ID:BBGInnovate,项目名称:bbgWPtheme,代码行数:31,代码来源:page-team.php
示例17: get_header
<?php
get_header();
$cur_cat_id = get_cat_id(single_cat_title("", false));
?>
<main class="clear-head white container">
<section class="page-title clear-head">
<h1><?php
single_cat_title('', true);
?>
</h1>
</section>
<div class="range-item-container">
<?php
query_posts(array('post_type' => array('materials', '3d-printers'), 'cat' => $cur_cat_id));
?>
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<div class="range-item">
<a href="<?php
the_permalink();
?>
">
<div>
<?php
$url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium');
开发者ID:Carfulan-Group,项目名称:SYS,代码行数:31,代码来源:category.php
示例18: importFromXML
/**
* Imports options and fields from the XML file given.
* @param $xmlFilename the file to import from.
* @return boolean true on success, false on failure
*/
function importFromXML($xmlFilename)
{
//parse the xml file
$xmlParser = new PhotoQXMLParser($xmlFilename);
$xmlParser->parse();
//store the parsed options if they validate
if ($xmlParser->validate()) {
$optionArray = $xmlParser->getParsedOptions();
$fieldArray = $xmlParser->getParsedFields();
$catsArray = $xmlParser->getParsedCats();
//right now we only support one default category
$defaultCat = null;
if (!empty($catsArray)) {
$defaultCat = $catsArray[0];
}
//delete views that are no longer used in the new settings
$this->_deleteObsoleteViews($this->getViewNames(), $xmlParser->getViewNames());
//delete image sizes that are no longer used in the new settings
$this->_deleteObsoleteImageSizes($this->getImageSizeNames(), $xmlParser->getImageSizeNames());
//add custom fields required by views setting of xml file,
//conflicts with fields will not happen as this is already tested in validation.
foreach ($xmlParser->getViewNames(true) as $view) {
$this->addViewCallback($view, true);
}
//it may happen that some fields are already there. Do not show an error in this case
$this->_errStack->pushCallback(array('PhotoQErrorHandler', 'mutePHOTOQ_FIELD_EXISTS'));
//create fields required by the xml file
foreach ($fieldArray as $fieldname) {
$this->_db->insertField($fieldname, true);
}
//add default tags to all photoq posts
if (isset($optionArray['qPostDefaultTags']['qPostDefaultTags']) && !empty($optionArray['qPostDefaultTags']['qPostDefaultTags'])) {
$newTags = preg_split("/[\\s]*,[\\s]*/", $optionArray['qPostDefaultTags']['qPostDefaultTags']);
$postIDs = $this->_db->getAllPublishedPhotoIDs();
foreach ($postIDs as $id) {
//update the tags in the database
wp_set_post_tags($id, add_magic_quotes($newTags), true);
}
//update all posts in the queue
$qEntries = $this->_db->getQueueIDTagPairs();
foreach ($qEntries as $entry) {
$oldTags = preg_split("/[\\s]*,[\\s]*/", $entry->q_tags);
$tagString = implode(',', array_unique(array_merge($newTags, $oldTags)));
$this->_db->updateTags($entry->q_img_id, $tagString);
}
}
//same for default category
if ($defaultCat) {
//create it if it does not exist
if (!category_exists($defaultCat)) {
$catID = wp_insert_category(array('cat_name' => $defaultCat));
if (is_wp_error($catID)) {
$defaultCat = NULL;
}
} else {
$catID = get_cat_id($defaultCat);
}
//get all posts and add default category to list of cats
$postIDs = $this->_db->getAllPublishedPhotoIDs();
foreach ($postIDs as $id) {
//update the tags in the database
wp_set_object_terms($id, $defaultCat, 'category', true);
}
//update all posts in the queue
if (!is_wp_error($catID)) {
$qIds = $this->_db->getAllQueuedPhotoIDs();
foreach ($qIds as $id) {
if (!in_array($catID, $this->_db->getCategoriesByImgId($id))) {
$this->_db->insertCategory($id, $catID);
}
}
}
}
//store the imported options to the database
$storedOptions = get_option($this->_optionsDBName);
foreach ($optionArray as $key => $val) {
if (array_key_exists($key, $storedOptions)) {
$storedOptions[$key] = PhotoQHelper::arrayHtmlEntities($val);
}
}
update_option($this->_optionsDBName, $storedOptions);
//reload to make the changes active
$this->load();
return true;
}
return false;
}
开发者ID:alx,项目名称:amandineleconte.fr,代码行数:92,代码来源:PhotoQOptionController.php
示例19:
</label><br class="clear" />
<input type="text" name="url" id="url" value="<?php
echo $comment_author_url;
?>
" />
</div>
<?php
}
?>
<div class="Smallbox">
<textarea name="comment" id="comment" cols="100%"></textarea>
</div>
<?php
if (in_category(get_cat_id('Companies')) || $in_subcategory_companies) {
?>
<input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php
} else {
?>
<input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php
}
?>
<input type="hidden" name="comment_post_ID" value="<?php
echo $id;
?>
" />
<?php
开发者ID:juslee,项目名称:e27,代码行数:31,代码来源:comments.php
示例20: fly_excerptlist_func
function fly_excerptlist_func($atts)
{
extract(shortcode_atts(array('titleonly' => 'n', 'cat' => '', 'num' => 5), $atts));
$args = array('posts_per_page' => $num);
$id = get_cat_id($cat);
$args['cat'] = $id;
$loop = new WP_Query($args);
$posts = array();
foreach ($loop->posts as $p) {
$posts[] = $p;
}
global $post;
$opost = $post;
ob_start();
ob_start();
$ret = apply_filters('excerptlist', $posts);
if (is_array($ret) || $ret == "" || $ret == " ") {
$ret = ob_get_contents();
}
ob_end_clean();
if (!is_array($ret) && $ret != "") {
} else {
if (strtolower($titleonly) != "y") {
$ret = '
<div class="excerptlist"> ';
foreach ($posts as $post) {
setup_postdata($post);
$ret .= ' <div class="articleexcerpt">
<div class="thumb">';
if (has_post_thumbnail()) {
$ret .= ' <a href="' . get_permalink($post->ID) . '">' . get_the_post_thumbnail($post->ID, array(125, 125), array('class' => 'articleimg')) . '</a>';
} else {
if (get_theme_option('art-thumb')) {
$ret .= '<a href="' . get_permalink($post->ID) . '"><img class="articleimg" src="' . get_theme_option('art-thumb') . '" alt="' . get_the_title($post->ID) . '" width="125" height="125" /></a>';
}
}
$ret .= '</div>
<h3 class="title"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . get_the_title($post->ID) . '</a></h3>';
if (!get_theme_option('bylines-hide-all')) {
$ret .= ' <div class="bylines">
' . (!get_theme_option("bylines-hide-date") ? get_the_time('F j, Y') : "") . '
' . (!get_theme_option("bylines-hide-author") ? "by" : "") . '
' . (!get_theme_option("bylines-hide-author") ? "<a href=\"" . get_author_posts_url(get_the_author_meta('ID')) . "\">" . get_the_modified_author() . " </a>" : "") . '
' . (!get_theme_option("bylines-hide-category") ? "posted in " : "") . '
' . (!get_theme_option("bylines-hide-category") ? get_the_category_list(', ', '', $post->ID) : "") . '
' . (!get_theme_option("bylines-hide-comment") ? '• <a href="' . get_permalink($post->ID) . '#comments"> ' . get_comments_number() . ' comments </a>' : "") . '
</div>';
}
$ret .= ' <p>' . get_the_excerpt() . '</p>
</div><!-- End of articleexcerpt --> ';
}
$post = $opost;
$ret .= '</div><!-- End of excerptlist --> ';
} else {
$ret = '<ul> ';
foreach ($posts as $post) {
setup_postdata($post);
$ret .= '<li class="exelist"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . get_the_title($post->ID) . '</a></li>';
}
$post = $opost;
$ret .= '</ul>';
}
}
return $ret;
}
开发者ID:christocmp,项目名称:bingopaws,代码行数:75,代码来源:excerpt-shortcode.php
注:本文中的get_cat_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论