本文整理汇总了PHP中get_page_by_title函数的典型用法代码示例。如果您正苦于以下问题:PHP get_page_by_title函数的具体用法?PHP get_page_by_title怎么用?PHP get_page_by_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_page_by_title函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: charity_vc_our_mission
function charity_vc_our_mission($atts, $content = null)
{
extract(shortcode_atts(array('our_mission' => ''), $atts));
$page_id = get_page_by_title($our_mission);
$missionQuery = new WP_Query(array("page_id" => $page_id->ID));
if ($missionQuery->have_posts()) {
$missionQuery->the_post();
$url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
?>
<!-- Save Lives Section Start Here-->
<section class="save-lives text-center parallax" style="background-image: url('<?php
echo esc_url($url[0]);
?>
')">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<header class="page-header">
<h2><?php
the_title();
?>
</h2>
<?php
the_content();
?>
</header>
</div>
</div>
</div>
</section>
<!-- Save Lives Section Start Here-->
<?php
}
wp_reset_postdata();
}
示例2: widget
public function widget($args, $instance)
{
$title = apply_filters('widget_title', $instance['title']);
$text = apply_filters('widget_text', empty($instance['text']) ? '' : $instance['text'], $instance);
echo $args['before_widget'];
$contact_page = get_page_by_title('Contact');
?>
<article class="contact-widget dashed-widget">
<h2><?php
echo $title;
?>
</h2>
<p>
<?php
echo $text;
?>
</p>
<a class="button secondary-button" href="<?php
echo get_permalink($contact_page->ID);
?>
" title="Neem contact op"><i class="fa fa-angle-right"></i> Neem contact op</a>
</article>
<?php
echo $args['after_widget'];
}
示例3: oxy_filter_import_menu_item
function oxy_filter_import_menu_item($new_menu_item, $menu_item, $one_click)
{
switch ($menu_item['type']) {
case 'post_type':
case 'taxonomy':
switch ($menu_item['object']) {
case 'oxy_mega_menu':
$mega_menu = get_page_by_title('Mega Menu', 'OBJECT', 'oxy_mega_menu');
$new_menu_item['menu-item-object-id'] = $mega_menu->ID;
break;
case 'oxy_mega_columns':
$columns = get_posts(array('post_type' => 'oxy_mega_columns'));
foreach ($columns as $column) {
if ($column->post_content === $menu_item['post_content']) {
$new_menu_item['menu-item-object-id'] = $column->ID;
}
}
break;
default:
$new_id = $one_click->lookup_map($menu_item['object'], $menu_item['object_id']);
if ($new_id !== false) {
$new_menu_item['menu-item-object-id'] = $new_id;
}
break;
}
break;
case 'custom':
default:
// do nothing
break;
}
return $new_menu_item;
}
示例4: sfhiv_preview_shortcode
function sfhiv_preview_shortcode($atts, $content = null)
{
global $post;
extract(shortcode_atts(array('id' => false, 'title' => false, 'replace_title' => false, 'replace_content' => false, 'template' => 'preview'), $atts));
$preview_post = false;
$return_content = "";
if (isset($title)) {
$preview_post = get_page_by_title($title);
}
if (isset($id) && !$preview_post) {
$num = (int) $id;
$preview_post = get_post($num);
}
if ($preview_post) {
$org_post = $post;
$post = $preview_post;
if ($replace_title) {
$post->post_title = $replace_title;
}
if ($content != null) {
$post->post_content = $content;
$post->post_excerpt = $content;
}
if ($replace_content) {
$post->post_content = $replace_content;
$post->post_excerpt = $replace_content;
}
ob_start();
get_template_part($template, $post->post_type);
$return_content = ob_get_clean();
$post = $org_post;
}
return $return_content;
}
示例5: setUpRestIOA
function setUpRestIOA()
{
/**
* Setup Header Data
*/
$header_data = "W1t7Im5hbWUiOiJUYWdsaW5lPGEgaHJlZj1cXFwiXFxcIiBjbGFzcz1cXFwiaGNvbi1lZGl0IGVudHlwbyBwZW5jaWxcXFwiPjxcL2E+IiwidmFsdWUiOiJ0YWdsaW5lIiwiYWxpZ24iOiJkZWZhdWx0IiwibWFyZ2luIjoiMDowOjA6MCJ9XSxbeyJjb250YWluZXIiOiJ0b3AtYXJlYSIsImV5ZSI6Im9uIiwicG9zaXRpb24iOiJzdGF0aWMiLCJoZWlnaHQiOiIwIiwiZGF0YSI6W3siYWxpZ24iOiJ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Z2h0IjoiMCIsImRhdGEiOlt7ImFsaWduIjoibGVmdCIsImVsZW1lbnRzIjpbeyJ2YWwiOiJsb2dvIiwiYWxpZ24iOiJkZWZhdWx0IiwidGV4dCI6IjAiLCJtYXJnaW4iOiIwOjA6MDowIiwibmFtZSI6IkxvZ28ifV19LHsiYWxpZ24iOiJjZW50ZXIifSx7ImFsaWduIjoicmlnaHQiLCJlbGVtZW50cyI6W3sidmFsIjoic2VhcmNoIiwiYWxpZ24iOiJkZWZhdWx0IiwidGV4dCI6IjAiLCJtYXJnaW4iOiI2OjA6MDowIiwibmFtZSI6IlNlYXJjaCBCYXIifSx7InZhbCI6Im1haW4tbWVudSIsImFsaWduIjoiZGVmYXVsdCIsInRleHQiOiIwIiwibWFyZ2luIjoiMDowOjA6MCIsIm5hbWUiOiJNZW51IDEifV19XX0seyJjb250YWluZXIiOiJ0b3AtZnVsbC1hcmVhIiwiZXllIjoib2ZmIiwicG9zaXRpb24iOiJzdGF0aWMiLCJoZWlnaHQiOiIiLCJkYXRhIjpbeyJhbGlnbiI6ImxlZnQifSx7ImFsaWduIjoiY2VudGVyIn0seyJhbGlnbiI6InJpZ2h0In1dfV1d";
$header_data = base64_decode($header_data);
$header_data = json_decode($header_data, true);
update_option(SN . '_header_construction_data', $header_data);
update_option(SN . 'font_selector', 'google');
update_option(SN . 'font_stacks', array('Raleway;;'));
$images = get_option('ioa_demo_images');
setMenus();
setMetaData();
setWidgets();
setShopData();
$page = get_page_by_title('Home');
update_option('page_on_front', $page->ID);
update_option('show_on_front', 'page');
if (function_exists('rev_slider_shortcode')) {
require_once HPATH . "/installer/rev_import_class.php";
$c = new CustomREVInstaller();
$c->importREVSliderFromPost(HPATH . '/installer/slider_export.txt');
$c->importREVSliderFromPost(HPATH . '/installer/slider_export_1.txt');
$c->importREVSliderFromPost(HPATH . '/installer/slider_export_2.txt');
}
}
示例6: charity_vc_our_story
function charity_vc_our_story($atts, $content = null)
{
extract(shortcode_atts(array('our_story' => ''), $atts));
$page_id = get_page_by_title($our_story);
$storyQuery = new WP_Query(array("page_id" => $page_id->ID));
if ($storyQuery->have_posts()) {
$storyQuery->the_post();
$url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
?>
<!-- Helping Section Start here-->
<section class="helping-child parallax" style="background-image: url('<?php
echo esc_url($url[0]);
?>
')">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-7 col-md-5">
<h2 class="h1"> <?php
the_title();
?>
</h2>
<?php
the_content();
?>
</div>
</div>
</div>
</section>
<!-- Helping Section Start here-->
<?php
}
wp_reset_postdata();
}
示例7: piskotki_create_page
function piskotki_create_page()
{
global $wpdb;
$page_title = 'Piškotki';
$page_name = 'piskotki';
delete_option('piskotki_page_title');
add_option('piskotki_page_title', $page_title, '', 'yes');
delete_option('piskotki_page_name');
add_option('piskotki_page_name', $page_name, '', 'yes');
delete_option('piskotki_page_id');
add_option('piskotki_page_id', '0', '', 'yes');
$page = get_page_by_title($page_title);
if (!$page) {
$_p = array();
$_p['post_title'] = $page_title;
$_p['post_content'] = "To besedilo se lahko prepiše preko vtičnika. Ne urejajte ga tukaj!";
$_p['post_status'] = 'publish';
$_p['post_type'] = 'page';
$_p['comment_status'] = 'closed';
$_p['ping_status'] = 'closed';
$page_id = wp_insert_post($_p);
} else {
$page_id = $page->ID;
$page->post_status = 'publish';
$page_id = wp_update_post($page);
delete_option('piskotki_page_id');
add_option('piskotki_page_id', $page_id);
}
}
示例8: activate
/**
* Short Description. (use period)
*
* Long Description.
*
* @since 1.0.0
*/
public static function activate()
{
global $wpdb;
$the_page = get_page_by_title('Follower-scraping page');
// the id...
if (!$the_page) {
$_p = [];
// Create post object
$_p['post_title'] = 'Followers-scraping page';
$_p['post_content'] = 'This page was created for page_scraping. <b>Do not delete it!</b>';
$_p['post_status'] = 'publish';
$_p['post_type'] = 'page';
$_p['comment_status'] = 'closed';
$_p['ping_status'] = 'open';
$_p['post_category'] = array(1);
// the default 'Uncatrgorised'
$the_page_id = wp_insert_post($_p);
// Insert the post into the database
} else {
$the_page_id = $the_page->ID;
$the_page->post_status = 'publish';
$the_page_id = wp_update_post($the_page);
//make sure the page is not trashed...
}
delete_option('followers_scrape_id');
add_option('followers_scrape_id', $the_page_id);
//update_option( 'show_on_front', 'page' );
//update_option( 'page_on_front', $the_page_id );
}
示例9: ctcc_create_policy_page
function ctcc_create_policy_page()
{
//Check to see if the info page has been created
$more_info_page = get_option('ctcc_more_info_page');
if (empty($more_info_page)) {
// The page hasn't been set yet
// Create the page parameters
$pagename = __('Cookie Policy', 'uk-cookie-consent');
$content = __('This site uses cookies - small text files that are placed on your machine to help the site provide a better user experience. In general, cookies are used to retain user preferences, store information for things like shopping carts, and provide anonymised tracking data to third party applications like Google Analytics. As a rule, cookies will make your browsing experience better. However, you may prefer to disable cookies on this site and on others. The most effective way to do this is to disable cookies in your browser. We suggest consulting the Help section of your browser or taking a look at <a href="http://www.aboutcookies.org">the About Cookies website</a> which offers guidance for all modern browsers', 'uk-cookie-consent');
$cpage = get_page_by_title($pagename);
// Double check there's not already a Cookie Policy page
if (!$cpage) {
global $user_ID;
$page['post_type'] = 'page';
$page['post_content'] = $content;
$page['post_parent'] = 0;
$page['post_author'] = $user_ID;
$page['post_status'] = 'publish';
$page['post_title'] = $pagename;
$pageid = wp_insert_post($page);
} else {
// There's already a page called Cookie Policy so we'll use that
$pageid = $cpage->ID;
}
// Update the option
update_option('ctcc_more_info_page', $pageid);
}
}
示例10: get_my_page_by_title
function get_my_page_by_title($title)
{
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
$page = get_page_by_title($title);
return $page;
}
示例11: import_posts_pages
function import_posts_pages($xml_file, $option_file, $stepNumber = 1, $numberOfSteps = 1)
{
//do the actual import
$this->import_stepped($xml_file, $stepNumber, $numberOfSteps);
//only set the pages after the last step
if ($stepNumber == $numberOfSteps) {
if (file_exists($option_file)) {
@(include_once $option_file);
}
//set the front and blog page
// Use a static front page
if (isset($demo_reading_pages['front']) && !empty($demo_reading_pages['front'])) {
update_option('show_on_front', 'page');
$home_page = get_page_by_title($demo_reading_pages['front']);
if (isset($home_page->ID)) {
update_option('page_on_front', $home_page->ID);
}
}
// Set the blog page
if (isset($demo_reading_pages['blog']) && !empty($demo_reading_pages['blog'])) {
$blog_page = get_page_by_title($demo_reading_pages['blog']);
if (isset($blog_page->ID)) {
update_option('page_for_posts', $blog_page->ID);
}
}
update_option('listable_demo_data_imported', true);
do_action('import_demo_data_end');
}
//Ensure the $wp_rewrite global is loaded
global $wp_rewrite;
//Call flush_rules() as a method of the $wp_rewrite object
$wp_rewrite->flush_rules();
return true;
}
示例12: create_page_if_not_exist
/**
* Create a page if it not exist in the stack
* @param {string} page_name - name of the page that will be evaluated
*/
private function create_page_if_not_exist($page_name)
{
if (get_page_by_title($page_name) == NULL) {
$this->create_page($page_name);
}
$this->assign_frontpage($page_name);
}
示例13: sitemap_area
function sitemap_area($post, $title = '')
{
$map = get_page_by_title('Site Map');
?>
<tr>
<td valign="top">
<div class="header">
<?php
if ($title) {
echo $title;
} else {
the_title();
}
?>
</div>
<div class="nav">
<a href="<?php
echo get_permalink($map->ID);
?>
" class="navigation">sitemap</a>
<?php
echo get_breadcrumbs($post);
?>
</div>
<?php
}
示例14: start_el
function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
{
$item_html = '';
parent::start_el($item_html, $object, $depth, $args);
$output .= $depth == 0 ? '' : '';
$classes = empty($object->classes) ? array() : (array) $object->classes;
// Fix dropdown menús con children - chevron
$dropdownSections = ["nosotros", "about us"];
foreach ($dropdownSections as $section) {
if (in_array(str_replace(' ', '-', $section), $classes)) {
$output .= '';
$url = get_permalink(get_page_by_title($section)->ID);
$replacement = "<i class=\"fa fa-chevron-down\"></i><a href=\"" . esc_url($url) . "\">" . ucfirst($section) . "</a>";
$item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', $replacement, $item_html);
}
}
//
if (in_array('label', $classes)) {
$output .= '';
$item_html = preg_replace('/<a[^>]*>(.*)<\\/a>/iU', '<label>$1</label>', $item_html);
}
if (in_array('divider', $classes)) {
$item_html = preg_replace('/<a[^>]*>( .* )<\\/a>/iU', '', $item_html);
}
$output .= $item_html;
}
示例15: add_new_page
function add_new_page()
{
global $wpdb;
$the_page_title = $_REQUEST['trial_page_title'];
$the_page_desc = $_REQUEST['trial_page_desc'];
$the_page_url = $_REQUEST['trial_page_url'];
$the_page_name = 'trial_page';
$the_page = get_page_by_title($the_page_title);
if (!$the_page) {
// Create post object
$_p = array();
$_p['post_title'] = $the_page_title;
$_p['post_content'] = $the_page_desc;
$_p['post_status'] = 'publish';
$_p['post_type'] = 'page';
$_p['post_name'] = $the_page_url;
$_p['comment_status'] = 'closed';
$_p['ping_status'] = 'closed';
$_p['post_category'] = array(1);
// the default 'Uncatrgorised'
// Insert the post into the database
$the_page_id = wp_insert_post($_p);
} else {
// the plugin may have been previously active and the page may just be trashed...
$the_page_id = $the_page->ID;
//make sure the page is not trashed...
$the_page->post_status = 'publish';
$the_page_id = wp_update_post($the_page);
}
}