本文整理汇总了PHP中get_page函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page函数的具体用法?PHP get_page怎么用?PHP get_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_page函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: base_getBreadcrumbs
function base_getBreadcrumbs()
{
if (is_404()) {
return false;
}
// Hack to fix breadcrumbs when you're viewing the news home
if (is_home()) {
$post = new \Timber\Post(get_option('page_for_posts'));
} else {
global $post;
}
$breadcrumbs = [];
if ($post->post_parent) {
$parent_id = $post->post_parent;
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = new \Timber\Post($page->ID);
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
}
// Add 'Blog Home' to breadcrumbs if you're on a news post or archive
if ((is_single() || is_archive()) && !is_search()) {
$breadcrumbs[] = new \Timber\Post(get_option('page_for_posts'));
}
return $breadcrumbs;
}
开发者ID:wearebase,项目名称:web-wordpress,代码行数:27,代码来源:breadcrumbs.php
示例2: show_content
function show_content($page_id, $is_mobile = false)
{
$page_data = get_page($page_id);
$content = $page_data->post_content;
$content = apply_filters('the_content', $content);
echo $content;
}
开发者ID:kaligari,项目名称:SoftBoot,代码行数:7,代码来源:functions.php
示例3: rss_check_feed_content
function rss_check_feed_content($url, $feed_config)
{
global $config;
if (strpos($url, '?') === false) {
$url .= '?kvs_test_feed=true';
} else {
$url .= '&kvs_test_feed=true';
}
$feed_contents = get_page('', $url, '', '', 1, 0, 600, '');
if (strlen($feed_contents) == 0) {
return null;
}
if ($feed_config['feed_charset'] != '' && function_exists('iconv')) {
$feed_contents = iconv($feed_config['feed_charset'], "utf8", $feed_contents);
}
preg_match_all("|<item>(.*?)</item>|is", $feed_contents, $temp);
$items = $temp[1];
$result = array();
foreach ($items as $item) {
$video_record = rss_parse_item($item);
$video_record['external_key'] = $video_record['website_link'];
return $video_record;
}
return null;
}
开发者ID:alexkot,项目名称:feed_tc,代码行数:25,代码来源:rss.php
示例4: merge_comment_count
function merge_comment_count($count, $post_ID)
{
// get all the languages for which this post exists
$languages = icl_get_languages('skip_missing=1');
$post = get_post($post_ID);
$type = $post->post_type;
foreach ($languages as $l) {
// in $count is already the count from the current language
if (!$l['active']) {
$otherID = icl_object_id($post_ID, $type, false, $l['language_code']);
if ($otherID) {
// cannot use call_user_func due to php regressions
if ($type == 'page') {
$otherpost = get_page($otherID);
} else {
$otherpost = get_post($otherID);
}
if ($otherpost) {
// increment comment count using translation post comment count.
$count = $count + $otherpost->comment_count;
}
}
}
}
return $count;
}
开发者ID:svenauhagen,项目名称:wpml-comments-merging,代码行数:26,代码来源:wpml-comments-merging.php
示例5: create_test_menus
/**
* create optional test nav menu
*
* At least two custom menus should be created in order to test a theme
* The standard Theme data file now ships with optimal menus built-in
* This method actually makes sense with custom WXR files only
*
* @since 0.2
*/
private function create_test_menus()
{
$pages = get_all_page_ids();
$items = array();
foreach ($pages as $page_ID) {
$info = get_page($page_ID);
$items[$info->post_title] = get_permalink($page_ID);
}
# pick three random entries
$random = array_rand($items, 3);
# build menus
$menus = array('Full Menu' => array('slug' => 'full-menu', 'menu_items' => $items), 'Short Menu' => array('slug' => 'short-menu', 'menu_items' => array($items[$random[0]], $items[$random[1]], $items[$random[2]])));
# register menus
foreach ($menus as $title => $data) {
register_nav_menu($data['slug'], $title);
if (false == is_nav_menu($title)) {
$menu_ID = wp_create_nav_menu($title);
foreach ($data['menu_items'] as $name => $url) {
$add_item = array('menu-item-type' => 'custom', 'menu-item-url' => $url, 'menu-item-title' => $name);
wp_update_nav_menu_item($menu_ID, 0, $add_item);
}
WP_CLI::success('Created menu ' . $title);
}
}
}
开发者ID:pixline,项目名称:wp-cli-theme-test-command,代码行数:34,代码来源:wp-cli-theme-test-command.php
示例6: start_el
function start_el(&$output, $page, $depth, $args, $current_page)
{
if ($depth) {
$indent = str_repeat("\t", $depth);
} else {
$indent = '';
}
extract($args, EXTR_SKIP);
$css_class = array('page_item', 'page-item-' . $page->ID);
if (!empty($current_page)) {
$_current_page = get_page($current_page);
_get_post_ancestors($_current_page);
if (isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors)) {
$css_class[] = 'current_page_ancestor';
}
if ($page->ID == $current_page) {
$css_class[] = 'current_page_item bodyguard';
// added bodyguard class to prevent current_page_item class from being removed
//Span injection sent to $output if active page
$active_arrow = '<span class="active"></span>';
} elseif ($_current_page && $page->ID == $_current_page->post_parent) {
$css_class[] = 'current_page_parent';
}
} elseif ($page->ID == get_option('page_for_posts')) {
$css_class[] = 'current_page_parent';
}
$css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
$output .= $indent . '<li class="' . $css_class . '">' . $active_arrow . '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(wp_strip_all_tags(apply_filters('the_title', $page->post_title, $page->ID))) . '">' . $link_before . apply_filters('the_title', $page->post_title, $page->ID) . $link_after . '</a>';
}
开发者ID:sezj,项目名称:ufl-template-responsive,代码行数:29,代码来源:walkers.php
示例7: myAjaxFunc
function myAjaxFunc()
{
/*
* vars
*/
$page_id = json_decode($_POST['postID']);
$page_object = get_page($page_id);
$content = $page_object->post_content;
$content = apply_filters('the_content', $content);
/*
* remove characters to get correct number of words count
*/
// remove from content string
$content = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $content);
// remove whitespaces after html tags from content string
$content = str_replace('> ', '', $content);
// return post content in json format
if (!empty($page_object)) {
header("Content-type: application/json");
echo json_encode(array('content' => $content));
return true;
} else {
return false;
}
}
开发者ID:Basbee,项目名称:wordpress-extended-content-analysis-yoast,代码行数:25,代码来源:get-post-content.php
示例8: add_custom_to_yoast
function add_custom_to_yoast($content)
{
global $post;
$pid = $post->ID;
$pg = get_page($pid);
$custom_content = '';
if ($post->post_name == 'feedback') {
$feedback_args = array('posts_per_page' => 4, 'post_type' => 'mp_feedback_cpt');
$feedback = get_posts($feedback_args);
$custom_content .= "<h2>Client " . get_the_title($post->ID) . "</h2>";
if (!empty($feedback)) {
foreach ($feedback as $fb) {
$custom_content .= '<div class="well text-center">';
$custom_content .= $fb->post_content;
$custom_content .= '</div>';
}
}
}
if ($post->post_name == 'case-studies') {
$case_study_args = array('posts_per_page' => 4, 'post_type' => 'mp_case_study_cpt');
$case_studies = get_posts($case_study_args);
$custom_content .= "<h2>Case Summaries</h2>";
if (!empty($case_studies)) {
foreach ($case_studies as $cs) {
$custom_content .= '<div class="well">';
$custom_content .= $cs->post_content;
$custom_content .= '</div>';
}
}
}
return $content . ' ' . $custom_content;
remove_filter('wpseo_pre_analysis_post_content', 'add_custom_to_yoast');
// don't let WP execute this twice
}
开发者ID:kevwaddell,项目名称:motopro-desktop,代码行数:34,代码来源:yoast_functions.php
示例9: wp_nav_menu_objects_filter
public function wp_nav_menu_objects_filter($items, $args)
{
if (is_array($items) && !empty($args->theme_location)) {
$home = false;
if (is_page()) {
if ($this->content->pageTemplate() === "page-home.php") {
$home = get_page_link(get_the_id());
}
}
foreach ($items as $id => $item) {
if (!empty($item->post_parent)) {
if ($item->object === "page") {
$page = get_page($item->object_id);
if (!empty($page->post_name)) {
$parent = get_page_link($item->post_parent);
$slug = $page->post_name;
$items[$id]->url = "{$parent}#{$slug}";
}
}
} else {
if ($item->url === $home) {
$items[$id]->url .= "#home";
}
}
}
}
return $items;
}
开发者ID:JeffreyBue,项目名称:jb,代码行数:28,代码来源:PeThemeVisia.php
示例10: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
echo $before_widget;
$page_data = get_page($instance['page_id']);
$title = $page_data->post_title;
$permalink = get_permalink($instance['page_id']);
$thumb = get_the_post_thumbnail($instance['page_id'], 'thumb-widget', array('class' => 'img-circle'));
if ($instance['display_thumb'] == 'on') {
echo '<a href="' . $permalink . '">' . $thumb . '</a>';
}
if (!empty($title) && $instance['display_title'] == 'on') {
if ($instance['link_title']) {
echo '<h2 class="entry-title"><a href="' . $permalink . '">' . $title . '</a></h2>';
} else {
echo '<h2 class="entry-title">' . $title . '</h2>';
}
}
echo '<p>';
echo $this->psw_trim($page_data->post_content, $instance['excerpt_length']);
if ($instance['dot_excerpt'] == 'on') {
echo ' [...]';
}
echo '</p>';
if ($instance['display_read_more'] == 'on') {
echo ' <a class="itek_psw_readmore" href="' . $permalink . '">' . $instance['read_more_label'] . '</a>';
}
echo $after_widget;
}
开发者ID:nakusyat,项目名称:temtour,代码行数:29,代码来源:itek-page-showcase.php
示例11: get_breadcrumb
function get_breadcrumb()
{
global $post;
$post->leafclass = ' breadcrumb-leaf';
$tmpid = $post->ID;
$parentid = $post->post_parent;
$pages = array($post);
while ($parentid) {
$tmppost = get_page($parentid);
$tmppost->leafclass = '';
$parentid = $tmppost->post_parent;
array_push($pages, $tmppost);
}
$pages = array_reverse($pages);
$trail = '<ul class="breadcrumb list-inline-block">';
$trail .= '<li class="breadcrumb-element breadcrumb-root">> <a href="' . home_url('/') . '">' . __('Home') . '</a></li>';
foreach ($pages as $p) {
$p->rootclass = ' breadcrumb-root';
if ($p->post_parent) {
$p->rootclass = '';
}
$trail .= ' | <li class="breadcrumb-element' . $p->leafclass . '"><a href="' . get_permalink($p->ID) . '">' . get_the_title($p->ID) . '</a></li>';
}
$trail .= '</ul>';
return $trail;
}
开发者ID:KaisarCode,项目名称:KC-WP-Kickoff-Theme,代码行数:26,代码来源:functions.php
示例12: occasions_breadcrumbs
/**
* Breadcrumbs
* - generates a list of breadcrumbs based off ancestors of current post
* $post - current post object
***********************/
function occasions_breadcrumbs($post)
{
// get an array of ancestor IDs
$parents = get_post_ancestors($post->ID);
// reverse the order of the ancestor IDs so that the first is the oldest ancestor
$parents = array_reverse($parents);
// if there are no ancestors, then we are on the top level
// if there are ancestors, lets generate some breadcrumbs
if ($parents != NULL) {
echo '<div class="oc_breadcrumb">';
// spit out a link to the ancestor followed by '>'
foreach ($parents as $parent) {
$the_parent = get_page($parent);
echo '<a href="' . get_permalink($parent) . '">';
echo $the_parent->post_title;
echo '</a>';
// if we are not at the current page, then leave a trailing '>'
if ($post->ID != $parent) {
echo '<span class="pipe">></span>';
}
}
// spit out the current page
echo $post->post_title;
echo '</div>';
}
}
开发者ID:heathervreeland,项目名称:Mediakit-Occasions-Online,代码行数:31,代码来源:breadcrumb.php
示例13: load_file
function load_file($url, $frequency = 3600, $cachefn = '')
{
$fcont = false;
if (!preg_match('|^http://([\\w]+)\\.deviantart\\.com[\\w/._]*|', $url)) {
die("Error: couldn't open {$url}!");
}
if ($cachefn !== '') {
$cache = '.cache/' . $cachefn;
} else {
$cache = '.cache/' . preg_replace('/[^a-z0-9\\.]/i', '', $url) . '.cache';
}
if (file_exists($cache) && time() - filemtime($cache) <= $frequency) {
$fcont = file_get_contents($cache);
} else {
if (($fcont = get_page($url)) === false) {
if (file_exists($cache)) {
touch($cache);
return load_file($url);
} else {
die("Error: couldn't open {$url}!");
}
}
file_put_contents($cache, $fcont, LOCK_EX);
}
return $fcont;
}
开发者ID:raisanen,项目名称:jce,代码行数:26,代码来源:load_file.php
示例14: excerpt
public function excerpt()
{
$id = $this->id;
global $post;
$old_post = $post;
if ($id != $post->ID) {
$post = get_page($id);
}
if (!($excerpt = trim($post->post_excerpt))) {
$excerpt = $post->post_content;
$excerpt = strip_shortcodes($excerpt);
$excerpt = apply_filters('the_content', $excerpt);
$excerpt = str_replace(']]>', ']]>', $excerpt);
$excerpt = strip_tags($excerpt);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$words = preg_split("/[\n\r\t ]+/", $excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if (count($words) > $excerpt_length) {
array_pop($words);
$excerpt = implode(' ', $words);
$excerpt = $excerpt . $excerpt_more;
} else {
$excerpt = implode(' ', $words);
}
}
$post = $old_post;
return $excerpt;
}
开发者ID:Telemedellin,项目名称:feriadelasfloresmedellin,代码行数:28,代码来源:PostsListRenderer.php
示例15: smarty_block_query
function smarty_block_query($params, $content, &$smarty, &$repeat)
{
global $db, $db_prefix, $query, $view;
if (isset($content)) {
echo $content;
return;
}
if (empty($params['var'])) {
$smarty->trigger_error("assign: missing 'var' parameter");
return;
}
$dbquery = html_to_db_query($query['submitted_query']);
$pagesize = get_pagesize($dbquery, $view);
$page = get_page($dbquery);
$options = array('pagesize' => $pagesize, 'page' => isset($dbquery['page']) ? intval($dbquery['page']) : 1);
$collectionid = $dbquery['collectionid'];
if ($collectionid == '-1') {
// search all collections, showing only a count of matching records
$options['count'] = 1;
$localCollections = query_local_collection_overview($dbquery, $options, $db, $db_prefix);
$remoteCollections = get_remote_collections_links($db, $db_prefix);
$result = array('result_type' => 'collections');
$result['rs'] = array_merge($localCollections, $remoteCollections);
// save the query structure in the session so that it can be re-used for an ajax request to get the remote counts
if (!empty($remoteCollections)) {
$remoteQueryStruct = transform_query($dbquery['querypiece'], true);
if (empty($_SESSION['queries'])) {
$_SESSION['queries'] = array();
}
$_SESSION['queries'][$_SESSION['counter']] = $remoteQueryStruct;
}
} else {
// search a particular collection
//error_reporting(E_ALL);
include_once $config['includepath'] . 'remote.inc.php';
if ($collection = get_remote_collection_info($collectionid)) {
// search a remote collection
$querystruct = transform_query($dbquery['querypiece'], true);
$url = "http://{$collection['host']}/{$collection['soap_url']}";
$soapparams = array('querystruct' => $querystruct, 'options' => $options);
$result = queryRemoteServer($url, 'queryOverview', $soapparams);
$result['local'] = 0;
$result['remoteCollection'] = $collectionid;
} else {
// search a local collection
$result = query_local_collection($dbquery, $options, $db, $db_prefix);
$result['local'] = 1;
$result['remoteCollection'] = 0;
}
$result['result_type'] = 'collection';
//debug($result);
//error_reporting(E_ALL);
}
if (!empty($result['error'])) {
$smarty->trigger_error($result['error']);
return;
}
//debug($result, false);
$smarty->assign($params['var'], $result);
}
开发者ID:prometheus-ev,项目名称:promdilps,代码行数:60,代码来源:block.query.php
示例16: userpro_entire_not_logged_in
function userpro_entire_not_logged_in()
{
global $userpro, $post;
$locked = userpro_get_option('site_guest_lockout');
$page_id = userpro_get_option('site_guest_lockout_pageid');
if ($locked && is_numeric($page_id) && !userpro_is_logged_in()) {
$condition = false;
$page_data = get_page($page_id);
if ($page_data->post_status == 'publish') {
$condition = true;
}
if ($condition == false) {
return;
}
if (isset($post->ID) && $post->ID == $page_id && $condition == true) {
return;
}
if (isset($post->ID)) {
$redirect_to = get_permalink($post->ID);
}
if (isset($redirect_to)) {
wp_redirect(add_query_arg('redirect_to', $redirect_to, get_permalink($page_id)));
} else {
wp_redirect(get_permalink($page_id));
}
exit;
}
}
开发者ID:ingridlima,项目名称:userpro-custom,代码行数:28,代码来源:template_redirects.php
示例17: contenidoPag
function contenidoPag()
{
get_page($page_id);
$page_data = get_page($page_id);
echo "<h2> {$page_data->post_title} </h2>";
echo apply_filters(‘the_content’, $page_data->post_content);
}
开发者ID:NandoFBP,项目名称:DidacticWP,代码行数:7,代码来源:functions.php
示例18: get_breadcrumbs
function get_breadcrumbs($post)
{
echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=" . get_bloginfo('url') . " itemprop=\"url\"><span itemprop=\"title\">Home</span></a><span class=arrow> > </span></li>";
if (is_home()) {
$breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_post_title($page->ID) . '</span></a><span class=arrow> > </span></li>';
} elseif (is_single() || is_page()) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . get_the_title($page->ID) . '</span></a><span class=arrow> > </span></li>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) {
echo $crumb;
}
echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><span itemprop=\"title\">" . $post->post_title . "</span></li>";
} elseif (is_category()) {
echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_cat_title($page->ID) . '</span></a></li>';
} elseif (is_archive()) {
echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">Archives</span></li>';
} elseif (is_404()) {
echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">404 Page Not Found</span></li>';
}
}
开发者ID:breakthroughdesign,项目名称:qaulitrol,代码行数:26,代码来源:functions.php
示例19: csv_check_feed_content
function csv_check_feed_content($url, $feed_config)
{
global $config;
if (strpos($url, '?') === false) {
$url .= '?kvs_test_feed=true';
} else {
$url .= '&kvs_test_feed=true';
}
$feed_contents = get_page('', $url, '', '', 1, 0, 600, '');
if (strlen($feed_contents) == 0) {
return null;
}
if ($feed_config['feed_charset'] != '' && function_exists('iconv')) {
$feed_contents = iconv($feed_config['feed_charset'], "utf8", $feed_contents);
}
$rows = explode("\n", $feed_contents);
$first_row = trim($rows[0]);
if ($feed_config['csv_skip_first_row'] == 1) {
if (count($rows) > 1) {
$first_row = trim($rows[1]);
} else {
return null;
}
}
if (function_exists('str_getcsv') && strlen($feed_config['separator']) == 1) {
$columns = array_map('trim', str_getcsv($first_row, $feed_config['separator']));
} else {
$columns = array_map('trim', explode($feed_config['separator'], $first_row));
}
return $columns;
}
开发者ID:alexkot,项目名称:feed_tc,代码行数:31,代码来源:csv.php
示例20: widget
function widget($args, $instance)
{
extract($args);
/* Our variables from the widget settings. */
$page_id = (int) $instance['page_id'];
if (empty($page_id) || $page_id < 1) {
return false;
}
$page_data = get_page($page_id);
$title = apply_filters('widget_title', trim($page_data->post_title), $instance, $this->id_base);
$link_title = (bool) $instance['link_title'];
if (!empty($page_data->post_content)) {
echo $before_widget;
get_the_image(array('post_id' => $page_data->ID, 'size' => 'featured-cat', 'width' => 310, 'height' => 220, 'before' => '<div class="post-thumb">', 'after' => '</div>'));
if ($title) {
echo $before_title;
if ($link_title) {
echo '<a href="' . esc_url(get_permalink($page_data->ID)) . '">';
}
echo $title;
if ($link_title) {
echo '</a>';
}
echo $after_title;
}
echo apply_filters('the_excerpt', trim($page_data->post_excerpt));
echo $after_widget;
}
}
开发者ID:MBerguer,项目名称:wp-demo,代码行数:29,代码来源:single-page.php
注:本文中的get_page函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论