本文整理汇总了PHP中in_category函数的典型用法代码示例。如果您正苦于以下问题:PHP in_category函数的具体用法?PHP in_category怎么用?PHP in_category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了in_category函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: k2_asides_permalink
function k2_asides_permalink($content)
{
if (in_category(get_option('unwakeable_asidescategory')) and !is_singular()) {
$content .= '<a href="' . get_permalink() . '" rel="bookmark" class="asides-permalink" title="' . k2_permalink_title(false) . '">(' . get_comments_number() . ')</a>';
}
return $content;
}
示例2: get_the_content_our_way
function get_the_content_our_way($more, $strip_teaser)
{
if (!in_category(array('tylerdibiasio', 'mishatownsend', 'korwinbriggs', 'twogirls', 'thefinerthings'))) {
$content = get_the_content($more, $strip_teaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return "{$content}";
} else {
//get the category
if (in_category('tylerdibiasio')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/tylerdibiasio\">";
} elseif (in_category('mishatownsend')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/mishatownsend\">";
} elseif (in_category('korwinbriggs')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/korwinbriggs\">";
} elseif (in_category('twogirls')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/twogirls\">";
} elseif (in_category('thefinerthings')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/thefinerthings\">";
}
$content = get_the_content($more, $strip_teaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = preg_replace('/(.*)(<a.*?href.*?\\>)/is', "\\1{$href}", $content);
return "{$content}";
}
}
示例3: layerslider
function layerslider($id = 0, $page = '')
{
// Check id
if (!isset($id) || empty($id)) {
echo '[LayerSlider WP] You need to specify the "id" parameter for the layerslider() function call';
return;
}
// Page filter
if (isset($page) && !empty($page)) {
// Get page name, ID and categories
$pagename = basename(get_permalink());
$pageid = (string) get_the_ID();
$categories = get_the_category();
// Get pages
$pages = explode(',', $page);
// Iterate over the pages
foreach ($pages as $page) {
if ($page == 'homepage' && is_front_page()) {
echo layerslider_init(array('id' => $id));
} elseif ($pageid == $page) {
echo layerslider_init(array('id' => $id));
} elseif ($pagename == $page) {
echo layerslider_init(array('id' => $id));
} elseif (in_category($page)) {
echo layerslider_init(array('id' => $id));
}
}
// All pages
} else {
echo layerslider_init(array('id' => $id));
}
}
示例4: wp_enqueue_scripts
function wp_enqueue_scripts()
{
// Remove Open Sans that WP adds from frontend
wp_deregister_style('open-sans');
wp_register_style('open-sans', false);
// Enqueue google fonts
$fonts = db_google_font_enqueue();
wp_enqueue_style('db-enqueue-fonts', $fonts);
wp_enqueue_script('jquery');
wp_enqueue_style('db-smartmenus', get_template_directory_uri() . '/js/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.css', array(), null, 'all');
wp_enqueue_style('db-lazyloadxt-fadein', get_template_directory_uri() . '/js/lazyloadxt/dist/jquery.lazyloadxt.fadein.css', array(), null, 'all');
wp_enqueue_style('db-header-style', get_template_directory_uri() . '/layouts/header.css');
wp_enqueue_style('db-footer-style', get_template_directory_uri() . '/layouts/footer.css');
wp_enqueue_style('db-content-sidebar', get_template_directory_uri() . '/layouts/content-sidebar.css');
$jsObject = array('ajaxurl' => admin_url('admin-ajax.php'), 'themeurl' => get_bloginfo('template_url'), 'is_tpl_default' => is_page() and !is_page_template());
wp_localize_script('jquery', 'db', $jsObject);
wp_enqueue_script('lazyloadxt', $this->templateURL . '/js/lazyloadxt/dist/jquery.lazyloadxt.js', array('jquery'));
wp_enqueue_script('bootstrap', $this->templateURL . '/js/bootstrap.min.js', array('jquery'));
wp_enqueue_script('smooth-scroll', $this->templateURL . '/js/smoothscroll.js', array('jquery'));
wp_enqueue_script('smartmenus', $this->templateURL . '/js/smartmenus/jquery.smartmenus.js', array('jquery'), false, true);
wp_enqueue_script('smartmenus-bootstrap', $this->templateURL . '/js/smartmenus/addons/bootstrap/jquery.smartmenus.bootstrap.js', array('jquery'), false, true);
wp_enqueue_script('imagesloaded', '//cdnjs.cloudflare.com/ajax/libs/jquery.imagesloaded/4.0.0/imagesloaded.pkgd.min.js', array('jquery'), false, true);
wp_enqueue_script('matchHeight', $this->templateURL . '/js/jquery.matchHeight-min.js', array('jquery'), false, true);
wp_enqueue_script('db', $this->templateURL . '/js/db.js', array('jquery'), false, true);
if (is_singular('post') && in_category('phan-cung')) {
wp_enqueue_script('bxslider', $this->templateURL . '/js/bxslider/jquery.bxslider.min.js', array('jquery'), false, true);
wp_enqueue_style('bxslider', get_template_directory_uri() . '/js/bxslider/jquery.bxslider.css', array(), null, 'all');
wp_enqueue_script('category-product', $this->templateURL . '/js/category-product.js', array('jquery', 'bxslider'), false, true);
}
wp_enqueue_style('db-common-style', get_template_directory_uri() . '/layouts/common.css', array('bootstrap'));
}
示例5: tarski_link_pages
/**
* Passes some Tarski-specific arguments to wp_link_pages.
*
* @since 2.0
*
* @uses wp_link_pages
*/
function tarski_link_pages()
{
$arguments = array('before' => '<p class="link-pages"><strong>' . __('Pages:', 'tarski') . '</strong>', 'after' => '</p>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'tarski'), 'previouspagelink' => __('Previous page', 'tarski'), 'pagelink' => '%', 'more_file' => '', 'echo' => true);
if (!(has_post_format('aside') || in_category(get_tarski_option('asidescategory')))) {
wp_link_pages($arguments);
}
}
示例6: pmpro_page_meta
function pmpro_page_meta()
{
global $membership_levels, $post, $wpdb;
$page_levels = $wpdb->get_col("SELECT membership_id FROM {$wpdb->pmpro_memberships_pages} WHERE page_id = '{$post->ID}'");
?>
<ul id="membershipschecklist" class="list:category categorychecklist form-no-clear">
<input type="hidden" name="pmpro_noncename" id="pmpro_noncename" value="<?php
echo wp_create_nonce(plugin_basename(__FILE__));
?>
" />
<?php
$in_member_cat = false;
foreach ($membership_levels as $level) {
?>
<li id="membership-level-<?php
echo $level->id;
?>
">
<label class="selectit">
<input id="in-membership-level-<?php
echo $level->id;
?>
" type="checkbox" <?php
if (in_array($level->id, $page_levels)) {
?>
checked="checked"<?php
}
?>
name="page_levels[]" value="<?php
echo $level->id;
?>
" />
<?php
echo $level->name;
//Check which categories are protected for this level
$protectedcategories = $wpdb->get_col("SELECT category_id FROM {$wpdb->pmpro_memberships_categories} WHERE membership_id = {$level->id}");
//See if this post is in any of the level's protected categories
if (in_category($protectedcategories, $post->id)) {
$in_member_cat = true;
echo ' *';
}
?>
</label>
</li>
<?php
}
?>
</ul>
<?php
if ('post' == get_post_type($post) && $in_member_cat) {
?>
<p class="pmpro_meta_notice">* <?php
_e("This post is already protected for this level because it is within a category that requires membership.", "pmpro");
?>
</p>
<?php
}
do_action('pmpro_after_require_membership_metabox', $post);
}
示例7: results_subscribe_scripts
function results_subscribe_scripts()
{
if (in_category(3) || is_home()) {
wp_register_script("results_subscribe", plugins_url("/index.min.js", __FILE__), ["jquery", "bootstrap-validator"], false, false);
wp_localize_script("results_subscribe", "resultsSubscribe", array("phpScriptURL" => plugin_dir_url(__FILE__) . "handle_subscribe.php"));
wp_enqueue_script("results_subscribe");
}
}
示例8: single_category_template
function single_category_template($st)
{
global $post;
if (in_category('servicios')) {
$st = TEMPLATEPATH . '/single-services.php';
}
return $st;
}
示例9: get_custom_cat_template
function get_custom_cat_template($single_template)
{
global $post;
if (in_category('adventure')) {
$single_template = dirname(__FILE__) . '/single-adventure.php';
}
return $single_template;
}
示例10: insert_exif
function insert_exif()
{
if (is_single() && in_category('118') || is_attachment()) {
global $post;
$args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID);
$attachments = get_posts($args);
foreach ($attachments as $attachment) {
$imgid = $attachment->ID;
$imgmeta = wp_get_attachment_metadata($imgid);
$latitude = $imgmeta['image_meta']['latitude'];
$longitude = $imgmeta['image_meta']['longitude'];
$lat_ref = $imgmeta['image_meta']['latitude_ref'];
$lng_ref = $imgmeta['image_meta']['longitude_ref'];
$lat = geo_single_fracs2dec($latitude);
$lng = geo_single_fracs2dec($longitude);
if ($lat_ref == 'S') {
$neg_lat = '-';
} else {
$neg_lat = '';
}
if ($lng_ref == 'W') {
$neg_lng = '-';
} else {
$neg_lng = '';
}
echo "<ul class='exif'>";
if (!empty($imgmeta['image_meta']['aperture'])) {
echo "<li>Aperture: f/" . $imgmeta['image_meta']['aperture'] . "</li>";
}
if (!empty($imgmeta['image_meta']['iso'])) {
echo "<li>ISO: " . $imgmeta['image_meta']['iso'] . "</li>";
}
if (!empty($imgmeta['image_meta']['shutter_speed'])) {
echo "<li>Shutter Speed: ";
if (1 / $imgmeta['image_meta']['shutter_speed'] > 1) {
echo "1/";
if (number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.3 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.5 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 1.6 or number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1) == 2.5) {
echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 1, '.', '') . " s</li>";
} else {
echo number_format(1 / $imgmeta['image_meta']['shutter_speed'], 0, '.', '') . " s</li>";
}
} else {
echo $imgmeta['image_meta']['shutter_speed'] . " s</li>";
}
}
if (!empty($imgmeta['image_meta']['focal_length'])) {
echo "<li>Focal Length: " . $imgmeta['image_meta']['focal_length'] . "mm</li>";
}
if (!empty($imgmeta['image_meta']['camera'])) {
echo "<li>Camera: " . $imgmeta['image_meta']['camera'] . "</li>";
}
if ($latitude != 0 && $longitude != 0) {
echo '<li>Location: <a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat, 6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">' . geo_pretty_fracs2dec($latitude) . $lat_ref . ' ' . geo_pretty_fracs2dec($longitude) . $lng_ref . '</a></li>';
}
echo "</ul>";
}
}
}
示例11: new_excerpt_more
function new_excerpt_more($more)
{
global $post;
if (in_category('news')) {
return '<a class="moretag" href="' . get_permalink($post->ID) . '"><img src="' . get_template_directory_uri() . '/dist/images/arrow-green-right.svg"></a>';
} elseif (in_category('datablog')) {
return '<a class="moretag" href="' . get_permalink($post->ID) . '"><img src="' . get_template_directory_uri() . '/dist/images/arrow-blue-right.svg"></a>';
}
}
示例12: king_in_category
/**
* @desc check in which category we are
* @param string $category - WP definition of siteareas like is_page, is_home
* @return boolean true/false
*/
function king_in_category($categories)
{
global $category_cache, $post;
$cat_ids = explode(',', $categories);
foreach ($cat_ids as $cat_id) {
if (in_category($cat_id)) {
return true;
}
}
}
示例13: dt_in_parent_category
function dt_in_parent_category($cats, $_post = null)
{
foreach ((array) $cats as $cat) {
$descendants = get_term_children((int) $cat, "category");
if ($descendants && in_category($descendants, $_post)) {
return true;
}
}
return false;
}
示例14: post_is_in_descendant_category
function post_is_in_descendant_category($cats, $_post = null)
{
foreach ((array) $cats as $cat) {
// get_term_children() accepts integer ID only
$descendants = get_term_children((int) $cat, 'category');
if ($descendants && in_category($descendants, $_post)) {
return true;
}
}
return false;
}
示例15: cp_post_in_desc_cat
/**
* Checks if blog post is in subcategory, used in CP 3.0.4 and earlier.
*
* @deprecated 3.0.5
*
* @param array $cats
* @param object $post (optional)
*
* @return bool
*/
function cp_post_in_desc_cat($cats, $post = null)
{
_deprecated_function(__FUNCTION__, '3.0.5');
foreach ((array) $cats as $cat) {
$descendants = get_term_children((int) $cat, 'category');
if ($descendants && in_category($descendants, $post)) {
return true;
}
}
return false;
}