本文整理汇总了PHP中get_queried_object_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_queried_object_id函数的具体用法?PHP get_queried_object_id怎么用?PHP get_queried_object_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_queried_object_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_inti_option
function get_inti_option($field_name, $option_array, $default = false, $meta_id = null)
{
// if meta_id isset then get the post meta
if (isset($meta_id)) {
$post_id = absint(get_queried_object_id());
// if posts page is set in reading settings get the page id
if ('page' == get_option('show_on_front') && get_option('page_for_posts') && is_home()) {
the_post();
$post_id = get_option('page_for_posts');
wp_reset_postdata();
}
// get the meta from the database
$meta = get_post_meta($post_id, $meta_id, true) ? get_post_meta($post_id, $meta_id, true) : null;
// if meta is an array check for the name in the array
if (is_array($meta)) {
$meta = $meta[$field_name];
}
// if meta isset return the value
if (isset($meta)) {
$meta = do_shortcode($meta);
return apply_filters("inti_meta_{$field_name}", $meta);
}
// if meta_id is null, then we're talking theme options, get the array of options
} else {
$options = get_option($option_array) ? get_option($option_array) : null;
}
// return the option if it exists
if (isset($options[$field_name])) {
return $options[$field_name];
}
// return default if nothing else
return $default;
}
开发者ID:waqastudios,项目名称:inti-foundation,代码行数:33,代码来源:get-options.php
示例2: document_title_parts_cb_s
function document_title_parts_cb_s($title)
{
if (is_single() and $id = get_queried_object_id()) {
$title[] = '#' . $id;
}
return $title;
}
开发者ID:systemo-biz,项目名称:add-id-in-title-wp,代码行数:7,代码来源:add-id-in-title.php
示例3: create
/**
* Factory method
*
* @param int $id
*
* @return MslsOptionsTax
*/
public static function create($id = 0)
{
if (is_admin()) {
$obj = MslsContentTypes::create();
$id = (int) $id;
$req = $obj->acl_request();
} else {
$id = get_queried_object_id();
$req = is_category() ? 'category' : (is_tag() ? 'post_tag' : '');
}
switch ($req) {
case 'category':
$options = new MslsOptionsTaxTermCategory($id);
break;
case 'post_tag':
$options = new MslsOptionsTaxTerm($id);
break;
default:
$options = new MslsOptionsTax($id);
}
if ($req) {
add_filter('check_url', array($options, 'check_base'), 9, 2);
} else {
global $wp_rewrite;
$options->with_front = !empty($wp_rewrite->extra_permastructs[$options->get_tax_query()]['with_front']);
}
return $options;
}
开发者ID:laishidua,项目名称:laishidua.com,代码行数:35,代码来源:MslsOptionsTax.php
示例4: shortcode
/**
* Shortcode Output
*/
public function shortcode()
{
/*
* Because it's possible to trigger inception, we need to keep track which
* level we are in, and reset the shortcode object accordingly.
*
* Clever alert. The ++ happens AFTER the value is read, So $my_level starts at 0.
*/
$my_level = self::$inception_levels++;
$args = $this->map_related_term_args($this->get_initial_query_args());
if (!$args) {
// We failed the related term check.
return '';
}
if (!isset($args['post__not_in']) && is_singular($this->sermons->post_type())) {
$args['post__not_in'] = array(get_queried_object_id());
}
$sermons = $this->sermons->get_many($args);
if (!$sermons->have_posts()) {
return '';
}
$max = $sermons->max_num_pages;
$sermons = $this->map_sermon_args($sermons, $my_level);
$content = '';
if (0 === $my_level) {
$content .= GCS_Style_Loader::get_template('list-item-style');
}
$args = $this->get_pagination($max);
$args['wrap_classes'] = $this->get_wrap_classes();
$args['sermons'] = $sermons;
$content .= GCS_Template_Loader::get_template('sermons-list', $args);
return $content;
}
开发者ID:jtsternberg,项目名称:gc-sermons,代码行数:36,代码来源:class-run.php
示例5: get_primary_category_id
static function get_primary_category_id()
{
if (empty(self::$post->ID)) {
return get_queried_object_id();
}
return self::$primary_category;
}
开发者ID:Vatia13,项目名称:tofido,代码行数:7,代码来源:td_global.php
示例6: display
public function display($post)
{
if (!empty($this->settings['page_template'])) {
//echo $this->settings['page_template'];
$page_template = get_page_template_slug(get_queried_object_id());
if ($page_template != $this->settings['page_template']) {
return false;
}
}
$this->postID = $post->ID;
wp_nonce_field($this->settings['id'], TF . '_' . $this->settings['id'] . '_nonce');
if (!empty($this->settings['desc'])) {
?>
<p class='description'><?php
echo $this->settings['desc'];
?>
</p><?php
}
?>
<table class="form-table tf-form-table">
<tbody>
<?php
foreach ($this->options as $option) {
$option->display();
}
?>
</tbody>
</table>
<?php
}
开发者ID:gambitph,项目名称:titan-framework,代码行数:30,代码来源:class-meta-box.php
示例7: outputFaqs
/**
* Outputs the entire chunk of FAQs
* @author Mike Biel <[email protected]>
*/
function outputFaqs()
{
//Gets the current page id
$post_id = get_queried_object_id();
$return = '';
$faqHTML = '';
$faqs = get_field('related_faqs', $post_id);
$show_adv_options = get_field('show_adv_options', $post_id);
if ($faqs) {
foreach ($faqs as $k => $f) {
// variable must be called $post (IMPORTANT)
// Question
$question = $this->faqQuestion(get_field('question', $f->ID), $f->ID, 0 == $k);
// Answer
$answer = $this->faqAnswer(get_field('answer', $f->ID), $f->ID, 0 == $k);
// Output Formatting
$faqHTML .= $this->formatFAQ($question, $answer);
}
$advOptions = $show_adv_options ? $this->outPutAdvancedExpHTML() : '';
$return = '
<!-- START THE FAQS!!1!1!111 -->
<div class="container-fluid">
<div class="row">
<div id="faqBlock" class="block">
' . $advOptions . '
<div class="group-holder">
' . $faqHTML . '
</div>
' . $advOptions . '
</div>
</div>
</div>';
}
return $return;
}
开发者ID:pjsinco,项目名称:doctorsthatdo,代码行数:39,代码来源:FAQs.php
示例8: force_members_login_init
/**
* function which forces all users to log in
*/
public static function force_members_login_init()
{
/* If the user is logged in, then abort */
if (current_user_can('read')) {
return;
}
/* get options to determine login page ID */
$options = ltp_options::get_options();
/* This is an array of pages that will be EXCLUDED from being blocked */
$exclusions = array('wp-cron.php', 'wp-trackback.php', 'xmlrpc.php');
/* If the current script name is in the exclusion list, abort */
if (in_array(basename($_SERVER['PHP_SELF']), $exclusions)) {
return;
}
/* if this is the login page, abort */
if (isset($options["login_page_id"])) {
if (get_queried_object_id() == $options["login_page_id"]) {
return;
}
/* Still here? Okay, then redirect to the login form */
self::redirect();
} else {
return;
}
}
开发者ID:Steadroy,项目名称:leeds-talent-pool,代码行数:28,代码来源:login.php
示例9: theme_layouts_get_layout
/**
* Gets the layout for the current post based off the 'Layout' custom field key if viewing a singular post
* entry. All other pages are given a default layout of 'layout-default'.
*
* @since 0.2.0
* @return string The layout for the given page.
*/
function theme_layouts_get_layout()
{
/* Get the available post layouts. */
$post_layouts = get_theme_support('theme-layouts');
/* Set the layout to an empty string. */
$layout = '';
/* If viewing a singular post, check if a layout has been specified. */
if (is_singular()) {
/* Get the current post ID. */
$post_id = get_queried_object_id();
/* Get the post layout. */
$layout = get_post_layout($post_id);
} elseif (is_author()) {
/* Get the current user ID. */
$user_id = get_queried_object_id();
/* Get the user layout. */
$layout = get_user_layout($user_id);
}
/* Make sure the given layout is in the array of available post layouts for the theme. */
if (empty($layout) || !in_array($layout, $post_layouts[0])) {
$layout = 'default';
}
/* @deprecated 0.2.0. Use the 'get_theme_layout' hook. */
$layout = apply_filters('get_post_layout', "layout-{$layout}");
/* Return the layout and allow plugin/theme developers to override it. */
return esc_attr(apply_filters('get_theme_layout', $layout));
}
开发者ID:nixter,项目名称:d.school,代码行数:34,代码来源:theme-layouts.php
示例10: custom_list_categories
function custom_list_categories($args = '')
{
$defaults = array('taxonomy' => 'category', 'show_option_none' => '', 'echo' => 1, 'depth' => 2, 'wrap_class' => '', 'level_class' => '', 'parent_title_format' => '%s', 'current_class' => 'current');
$r = wp_parse_args($args, $defaults);
if (!isset($r['wrap_class'])) {
$r['wrap_class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
}
extract($r);
if (!taxonomy_exists($taxonomy)) {
return false;
}
$categories = get_categories($r);
$output = "<ul class='" . esc_attr($wrap_class) . "'>" . PHP_EOL;
if (empty($categories)) {
if (!empty($show_option_none)) {
$output .= "<li>" . $show_option_none . "</li>" . PHP_EOL;
}
} else {
if (is_category() || is_tax() || is_tag()) {
$current_term_object = get_queried_object();
if ($r['taxonomy'] == $current_term_object->taxonomy) {
$r['current_category'] = get_queried_object_id();
}
}
$depth = $r['depth'];
$walker = new My_Category_Walker();
$output .= $walker->walk($categories, $depth, $r);
}
$output .= "</ul>" . PHP_EOL;
if ($echo) {
echo $output;
} else {
return $output;
}
}
开发者ID:binhdarkcu,项目名称:shoping_quan,代码行数:35,代码来源:functions.php
示例11: add_script_vars
public function add_script_vars()
{
$post_id = get_queried_object_id();
?>
<script type="text/javascript">
var optinoid = {
id: '<?php
echo get_queried_object_id();
?>
',
api_url: '<?php
echo admin_url('admin-ajax.php');
?>
',
nonce: '<?php
echo wp_create_nonce('optinoid');
?>
',
is_home: <?php
echo is_front_page() ? 1 : 0;
?>
};
</script>
<?php
}
开发者ID:stefanolaru,项目名称:optinoid,代码行数:25,代码来源:Output.php
示例12: widget
/**
* Outputs the widget based on the arguments input through the widget controls.
*
* @since 0.1.0
* @access public
* @return void
*/
public function widget($sidebar, $instance)
{
extract($sidebar);
/* If not viewing a single post, bail. */
if (!is_singular()) {
return;
}
/* Get the current post ID. */
$post_id = get_queried_object_id();
/* Get the snippet content and title. */
$snippet_content = get_post_meta($post_id, 'Snippet', true);
$snippet_title = get_post_meta($post_id, 'Snippet Title', true);
/* If there's no snippet content, bail. */
if (empty($snippet_content)) {
return false;
}
/* If there's a custom snippet title, use it. Otherwise, default to the widget title. */
$instance['title'] = !empty($snippet_title) ? $snippet_title : $instance['title'];
/* Output the theme's widget wrapper. */
echo $before_widget;
/* If a title was input by the user, display it. */
if (!empty($instance['title'])) {
echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
}
/* Output the snippet. */
printf('<div class="snippet-content">%s</div>', apply_filters('my_snippets_content', $snippet_content));
/* Close the theme's widget wrapper. */
echo $after_widget;
}
开发者ID:ThemeSurgeon,项目名称:my-snippets,代码行数:36,代码来源:class-widget-snippet.php
示例13: handle_form_submission
public function handle_form_submission()
{
if (get_queried_object_id() != $this->get_page_id()) {
return false;
}
$action = $this->get_action();
if (get_query_var('cuar_action', null) != null) {
$action = get_query_var('cuar_action', null);
}
if (!$this->is_action_authorized($action)) {
return false;
}
do_action('cuar/private-content/edit/before_' . $action, $this, $this->form_errors);
do_action('cuar/private-content/edit/before_' . $action . '/page-slug=' . $this->get_slug(), $this, $this->form_errors);
$result = $this->do_edit_content($action, $_POST);
do_action('cuar/private-content/edit/after_' . $action, $this, $this->form_errors);
do_action('cuar/private-content/edit/after_' . $action . '/page-slug=' . $this->get_slug(), $this, $this->form_errors);
if (true === $result && empty($this->form_errors)) {
$redirect_url = apply_filters('cuar/private-content/edit/after_' . $action . '/redirect_url', $this->get_redirect_url_after_action(), $this->get_slug());
if ($redirect_url != null) {
wp_redirect($redirect_url);
exit;
}
}
return true;
}
开发者ID:joasssko,项目名称:schk,代码行数:26,代码来源:addon-edit-content-page.class.php
示例14: widget
function widget($args, $instance)
{
extract($args);
$user_id = $instance['user_id'];
if (empty($user_id)) {
if (is_author()) {
$user_id = get_queried_object_id();
} else {
return;
}
}
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$title = sprintf($instance['title'], '<span class="display-name">' . get_the_author_meta('display_name', $user_id) . '</span>');
$bio = get_the_author_meta('description', $user_id);
if ($instance['strip_tags']) {
$bio = strip_tags($bio);
}
if (function_exists('mb_strimwidth') && ($bio_length = $instance['bio_length'])) {
$bio = mb_strimwidth($bio, 0, $bio_length);
}
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
echo '<div class="bio">' . wpautop($bio) . '</div>';
echo $after_widget;
}
开发者ID:alphadc,项目名称:xiuxing,代码行数:27,代码来源:widget-user-bio.php
示例15: cherry_post_inline_styles
/**
* Get post specific CSS styles and paste it to head.
*
* @since 4.0.0
*/
function cherry_post_inline_styles()
{
$post_id = get_queried_object_id();
$post_type = get_post_type($post_id);
if (!$post_type || !post_type_supports($post_type, 'cherry-post-style')) {
return;
}
if (wp_style_is(CHERRY_DYNAMIC_CSS_HANDLE, 'enqueued')) {
$handle = CHERRY_DYNAMIC_CSS_HANDLE;
} else {
$cherry_styles = cherry_get_styles();
$handle = isset($cherry_styles['style']) ? $cherry_styles['style']['handle'] : false;
}
if (!$handle) {
return;
}
$header_bg = cherry_current_page()->get_property('background', 'header');
if (!$header_bg) {
return;
}
$custom_bg = cherry_get_background_css('.site-header', $header_bg);
/**
* Filter a custom background style.
*
* @since 4.0.0
* @param string $custom_bg Background style.
* @param int $post_id The post ID.
*/
$custom_bg = apply_filters('cherry_post_inline_styles', $custom_bg, $post_id);
if (!$custom_bg) {
return;
}
wp_add_inline_style($handle, sanitize_text_field($custom_bg));
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:39,代码来源:styles.php
示例16: zfwca_list_categories
/**
* Display a list categories
* @param array $args
* @return bool
*/
function zfwca_list_categories($args = array())
{
$defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'exclude_tree' => '', 'current_category' => 0, 'taxonomy' => 'category');
$r = wp_parse_args($args, $defaults);
$r['walker'] = new ZFWCA_Post_Category_Walker();
if (!isset($r['class'])) {
$r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
}
extract($r);
if (!taxonomy_exists($taxonomy)) {
return false;
}
$categories = get_categories($r);
$output = '';
if (empty($categories)) {
$output .= 'No categories';
} else {
if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
$current_term_object = get_queried_object();
if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
$r['current_category'] = get_queried_object_id();
}
}
$output .= walk_category_tree($categories, 0, $r);
}
$output = apply_filters('zfwca_wp_list_categories', $output, $args);
return $output;
}
开发者ID:Juni4567,项目名称:meritscholarship,代码行数:33,代码来源:functions.php
示例17: jetpack_breadcrumbs
/**
* Plugin Name: Site Breadcrumbs
* Plugin URI: https://wordpress.com
* Description: Quickly add breadcrumbs to the single view of a hierarchical post type or a hierarchical taxonomy.
* Author: Automattic
* Version: 1.0
* Author URI: https://wordpress.com
* License: GPL2 or later
*/
function jetpack_breadcrumbs()
{
$taxonomy = is_category() ? 'category' : get_query_var('taxonomy');
$is_taxonomy_hierarchical = is_taxonomy_hierarchical($taxonomy);
$post_type = is_page() ? 'page' : get_query_var('post_type');
$is_post_type_hierarchical = is_post_type_hierarchical($post_type);
if (!($is_post_type_hierarchical || $is_taxonomy_hierarchical) || is_front_page()) {
return;
}
$breadcrumb = '';
if ($is_post_type_hierarchical) {
$post_id = get_queried_object_id();
$ancestors = array_reverse(get_post_ancestors($post_id));
if ($ancestors) {
foreach ($ancestors as $ancestor) {
$breadcrumb .= '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="' . esc_url(get_permalink($ancestor)) . '" itemprop="item"><span itemprop="name">' . esc_html(get_the_title($ancestor)) . '</span></a></span>';
}
}
$breadcrumb .= '<span class="current-page" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">' . esc_html(get_the_title($post_id)) . '</span></span>';
} elseif ($is_taxonomy_hierarchical) {
$current = get_term(get_queried_object_id(), $taxonomy);
if (is_wp_error($current)) {
return;
}
if ($current->parent) {
$breadcrumb = jetpack_get_term_parents($current->parent, $taxonomy);
}
$breadcrumb .= '<span class="current-category" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">' . esc_html($current->name) . '</span></span>';
}
$home = '<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="' . esc_url(home_url('/')) . '" class="home-link" itemprop="item" rel="home"><span itemprop="name">' . esc_html__('Home', 'jetpack') . '</span></a></span>';
echo '<nav class="entry-breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">' . $home . $breadcrumb . '</nav>';
}
开发者ID:kanei,项目名称:vantuch.cz,代码行数:41,代码来源:site-breadcrumbs.php
示例18: get_language_from_content
/**
* 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);
}
开发者ID:JoryHogeveen,项目名称:polylang,代码行数:35,代码来源:choose-lang-content.php
示例19: run
/**
* the_content filter that will add linked posts to the bottom of the main post content
*
* @param $content
*
* @return string
*/
public function run($content)
{
/**
* Wow, what's going on here?! Well, setup_postdata() sets a lot of variables but does not change the $post variable.
* All checks return the main queried ID but we want to check if this specific filter call is the for the 'main' content.
* The method setup_postdata() does global and set the $id variable, so we're checking that.
*/
global $id;
// Only run on single
if (!is_singular() || !is_main_query() || $id != get_queried_object_id()) {
return $content;
}
// Allow disabling content filter
if (false === apply_filters('rp4wp_append_content', true)) {
return $content;
}
// The Post Type
$post_type = get_post_type($id);
// The Post Type Manager
$pt_manager = new RP4WP_Post_Type_Manager();
// Check if this Post Type is installed
if ($pt_manager->is_post_type_installed($post_type) && isset(RP4WP()->settings['general_' . $post_type])) {
// Related Post Manager
$related_post_manager = new RP4WP_Related_Post_Manager();
// The Output
$output = $related_post_manager->generate_related_posts_list($id);
// Add output if there is any
if ('' != $output) {
$content .= $output;
}
}
// Return the content
return $content;
}
开发者ID:amprog,项目名称:relatedpostsforwp,代码行数:41,代码来源:class-filter-after-post.php
示例20: tamatebako_get_post_layout
/**
* Get the post layout based on the given post ID.
*/
function tamatebako_get_post_layout($post_id = '')
{
if (empty($post_id)) {
$post_id = get_queried_object_id();
}
return get_post_meta($post_id, tamatebako_layout_meta_key(), true);
}
开发者ID:WPDevHQ,项目名称:nevertheless,代码行数:10,代码来源:post-meta.php
注:本文中的get_queried_object_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论