本文整理汇总了PHP中get_page函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page函数的具体用法?PHP get_page怎么用?PHP get_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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>';
}
示例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;
}
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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>';
}
}
示例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;
}
示例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;
}
示例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);
}