本文整理汇总了PHP中get_the_permalink函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_permalink函数的具体用法?PHP get_the_permalink怎么用?PHP get_the_permalink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_permalink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
/** @see WP_Widget::widget */
function widget($args, $instance)
{
$args['id'] = isset($args['id']) ? $args['id'] : 'I4Web_LMS_Announcements_Widget';
$instance['title'] = isset($instance['title']) ? $instance['title'] : '';
$title = $instance['title'];
echo $args['before_widget'];
if ($title) {
echo $args['before_title'] . $title . $args['after_title'];
}
// Start the query for the latest 3 posts
$args = array('post_type' => array('post'), 'posts_per_page' => 3);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
echo '<ul class="announcements-list no-bullet">';
if (has_post_thumbnail()) {
echo '<li><span class="announcement-feat-img">' . get_the_post_thumbnail($post_id, array(100, 100)) . '</span><a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
} else {
echo '<li><a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
}
echo '<p>' . i4_lms_posted_on() . '</p>
</li>
</ul>';
}
$posts_page = get_option('page_for_posts');
//Get the ID of the page set as the Posts Page
echo '<a href="' . get_permalink($posts_page) . '" class="button expand">Read All</a>';
wp_reset_postdata();
} else {
echo '<p>Sorry, there are no announcements available at this time</p>';
}
echo $args['after_widget'];
}
示例2: rt_social_media_share
/**
* Social Media Share Shortcode
*
* @global class $post
*
* @param array $atts
* @param string $content
* @return string $output
*/
function rt_social_media_share($atts = array(), $content = null)
{
global $post;
//Available Social Media Icons
$rt_social_share_list = apply_filters("rt_social_media_list", array("Email" => array("icon_name" => "mail", "url" => "mailto:?body=[URL]", "popup" => false), "Twitter" => array("icon_name" => "twitter", "url" => "http://twitter.com/home?status=[TITLE]+[URL]", "popup" => true), "Facebook" => array("icon_name" => "facebook", "url" => "http://www.facebook.com/sharer/sharer.php?u=[URL]&title=[TITLE]", "popup" => true), "Google +" => array("icon_name" => "gplus", "url" => "https://plus.google.com/share?url=[URL]", "popup" => true), "Pinterest" => array("icon_name" => "pinterest", "url" => "http://pinterest.com/pin/create/bookmarklet/?media=[MEDIA]&url=[URL]&is_video=false&description=[TITLE]", "popup" => true), "Tumblr" => array("icon_name" => "tumblr", "url" => "http://tumblr.com/share?url=[URL]&title=[TITLE]", "popup" => true), "Linkedin" => array("icon_name" => "linkedin", "url" => "http://www.linkedin.com/shareArticle?mini=true&url=[URL]&title=[TITLE]&source=", "popup" => true), "Vkontakte" => array("icon_name" => "vkontakte", "url" => "http://vkontakte.ru/share.php?url=[URL]", "popup" => true)));
$title = urlencode(get_the_title($post->ID));
$permalink = urlencode(get_the_permalink($post->ID));
$image = urlencode(rt_get_attachment_image_src(get_post_thumbnail_id($post->ID)));
$output = "";
foreach ($rt_social_share_list as $key => $value) {
$value["url"] = str_replace("[URL]", $permalink, $value["url"]);
$value["url"] = str_replace("[TITLE]", $title, $value["url"]);
$value["url"] = str_replace("[MEDIA]", $image, $value["url"]);
$output .= '<li class="' . $value["icon_name"] . '">';
$output .= $value["popup"] ? '<a class="icon-' . $value["icon_name"] . ' " href="#" data-url="' . $value["url"] . '" title="' . $key . '">' : '<a class="icon-' . $value["icon_name"] . ' " href="' . $value["url"] . '" title="' . $key . '">';
$output .= '<span>' . $key . '</span>';
$output .= '</a>';
$output .= '</li>';
}
return '
<div class="social_share_holder">
<div class="share_text"><span class="icon-share">' . __("Share", "rt_theme") . '</span></div>
<ul class="social_media">' . $output . '</ul>
</div>';
}
示例3: getRecent
/**
* Latest blog posts
*
* @param int $limit post display limit
*
* @param string $thumbnail_size
*
* @return array
*/
public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
{
$args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
$array_out = array();
$recent_posts = \get_posts(\wp_parse_args($args));
/*$like_bool = Option::get_theme_option( 'blog_list_like' );
if ( $like_bool === '1' ) {
$PostLike = \SilverWp\Ajax\PostLike::getInstance();
}*/
foreach ($recent_posts as $key => $recent) {
\setup_postdata($recent);
$post_id = $recent->ID;
//$array_out[ $key ] = $recent;
$array_out[$key]['ID'] = $post_id;
$array_out[$key]['post_title'] = \get_the_title($post_id);
$array_out[$key]['url'] = \get_the_permalink($post_id);
$array_out[$key]['post_author'] = \get_the_author();
$array_out[$key]['post_date'] = \get_the_date('', $post_id);
$array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
//$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
$array_out[$key]['post_comment_count'] = $recent->comment_count;
if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
$array_out[$key]['post_excerpt'] = \get_the_excerpt();
} else {
$array_out[$key]['post_excerpt'] = $recent->post_excerpt;
}
$array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
// Thumbnail
$array_out[$key]['categories'] = self::getTaxonomy($post_id);
}
\wp_reset_postdata();
return $array_out;
}
示例4: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance)
{
echo $args['before_widget'];
$display_title = !empty($instance['display_title']) ? $instance['display_title'] : '';
$numberofposts = !empty($instance['numberofposts']) ? absint($instance['numberofposts']) : '';
if ($display_title == 'on') {
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
}
}
$post_query_args = array('post_type' => array('post'), 'pagination' => false, 'posts_per_page' => $numberofposts, 'ignore_sticky_posts' => true, 'cache_results' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => true);
$post_query = new WP_Query($post_query_args);
if ($post_query->have_posts()) {
while ($post_query->have_posts()) {
$post_query->the_post();
global $post;
$output = '';
$output .= '<div class="widget-recent-post clearfix">';
$output .= has_post_thumbnail($post->ID) ? '<div class="recent-post-image">' : '';
$output .= has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'illdy-widget-recent-posts') : '';
$output .= has_post_thumbnail($post->ID) ? '</div><!--/.recent-post-image-->' : '';
$output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . esc_attr(get_the_title()) . '" class="recent-post-title">' . esc_html(get_the_title()) . '</a>';
$output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . __('More...', 'illdy') . '" class="recent-post-button">' . __('More...', 'illdy') . '</a>';
$output .= '</div><!--/.widget-recent-post.clearfix-->';
echo $output;
}
} else {
echo __('No posts found.', 'illdy');
}
wp_reset_postdata();
echo $args['after_widget'];
}
示例5: bl_posttype_shortcodes_showposts
function bl_posttype_shortcodes_showposts($params = array())
{
// Pulls the paramater values passed from the shortcode options
extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
// Builds the query based on the available params
$query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
// Looks for the presence of any qualifying posts inside the defined loop
if ($query->have_posts()) {
// We open the post container only where specified posts are available
$shortcodeOutput = '<div>';
while ($query->have_posts()) {
$query->the_post();
// Wraps each qualifying post for output in an <article> tag with Schema data.
$shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
$shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
$shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
$shortcodeOutput .= '</a>';
$shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
$shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
$shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
$shortcodeOutput .= '<article>';
}
// Closes off the parent container
$shortcodeOutput .= '</div>';
}
// Resets the wordpress loop
wp_reset_postdata();
// Returns the concatenated shortcodeOutput to the page
return $shortcodeOutput;
}
示例6: Add_Post_To_H1_Recent_Posts_From_Network
/**
* This function actually adds the post to the list of network recent posts when it is published for the first time.
*
* If the content on the post is empty then the title will be 'Auto Draft' and so it is not added to the list
* until it is published with content. Once a post has made it to the list it is never added back to the beginning.
* That is, if you update the post it will not come back on to the list, nor would it move to the front if it was
* already on the list.
*/
function Add_Post_To_H1_Recent_Posts_From_Network()
{
global $post;
if ($post->post_title == __('Auto Draft')) {
return;
}
if (!get_post_meta($post->ID, 'published_once', true) && ($post->ID != 1 || strpos($post->content, $this->first_post) === false)) {
global $wpdb;
$domains = array();
$blog_id = get_current_blog_id();
// Ignore main site posts
if ($blog_id == BLOG_ID_CURRENT_SITE) {
return;
}
$rows = $wpdb->get_results("SELECT * FROM {$wpdb->dmtable} WHERE `blog_id`={$blog_id} ORDER BY id DESC LIMIT 0,1");
foreach ($rows as $key => $val) {
$domains[] = 'http://' . $val->domain;
}
$orig_blogurl = get_option('home') ? get_option('home') : get_option('siteurl');
$mapped_blogurl = count($domains) > 0 ? $domains[0] : $orig_blogurl;
$thumbnail = get_the_post_thumbnail($post->ID, 'medium', array('class' => 'hrpn-alignleft hrpn-thumb'));
$essential_post_data = array('title' => $post->post_title, 'permalink' => str_replace($orig_blogurl, $mapped_blogurl, get_the_permalink($post->ID)), 'thumbnail' => $thumbnail, 'date' => $post->post_date);
$current_recent_posts = get_site_option('network_latest_posts');
if (empty($current_recent_posts)) {
$current_recent_posts = array();
}
array_unshift($current_recent_posts, $essential_post_data);
$new_recent_posts = array_slice($current_recent_posts, 0, 50);
update_site_option('network_latest_posts', $new_recent_posts);
update_post_meta($post->ID, 'published_once', 'true');
}
}
开发者ID:ZeelandFamily,项目名称:h1-recent-posts-from-network,代码行数:40,代码来源:HerculesRecentPostsfromNetwork.php
示例7: check_referer_link
/** # CHECK_REFERER_LINK
*
*
*/
public function check_referer_link()
{
if (isset($_POST['ykdi_referer'])) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var href = '<?php
echo get_the_permalink(intval($_POST['ykdi_referer']));
?>
';
var html = '<p>If you\'re not redirected in five seconds, click the link below.</p>';
html += '<p><a href="<?php
echo get_the_permalink(intval($_POST['ykdi_referer']));
?>
">Back to page</a></p>';
$( '#signup_form' ).append(html);
setTimeout(function() {
window.location.href = href;
}, 5000);
});
</script>
<?php
}
}
示例8: widget
/**
* front-end display of the widget
*
* @param $args widget arguments
* @param $instance saved values from database
*/
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$page_id = apply_filters('page_thumbani_page_id', $instance['page_id']);
$thumbnail_size = apply_filters('page_thumbani_thumbnail_size', $instance['thumbnail_size']);
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$wp_query = new WP_Query(array('page_id' => $page_id));
if ($wp_query->have_posts()) {
while ($wp_query->have_posts()) {
$wp_query->the_post();
?>
<div class="text-center page-thumbnail-widget--content circle-hover">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail($thumbnail_size, array('class' => 'img-center img-circle img-responsive'));
}
?>
</div>
<?php
the_title('<div class="row"><div class="col-md-10 col-md-offset-1 text-center"><h3 class="page-thumbnail-title"><a href="' . get_the_permalink() . '">', '</a></h3></div></div>');
?>
<?php
}
}
wp_reset_query();
echo $after_widget;
}
示例9: get_share_url
/**
* Returns the share URL.
*
* @since 1.0.0
* @return string
*/
public function get_share_url()
{
// TODO sharer.php no longer accepts custom post paramters (e.g title) and just retries the OG
// params for the page. The modern way is to use the share dialog, but that requires the user
// to have registered an app on Facebook - we should support both.
return 'https://www.facebook.com/sharer/sharer.php?u=' . urlencode(get_the_permalink());
}
示例10: slider
function slider($queried_posts)
{
global $post;
?>
<section class="l-clear js-flickity m-flickity" data-flickity-options='{ "cellAlign": "left", "contain": true, "prevNextButtons": false, "wrapAround": true, "autoPlay": true}'>
<?php
foreach ($queried_posts as $post) {
setup_postdata($post);
echo '<a class="gallery-cell m-prf ratio-4-3 overlay" href="' . get_the_permalink() . '" title="' . get_the_title() . '">';
if (function_exists('makeitSrcset') && has_post_thumbnail()) {
makeitSrcset(get_post_thumbnail_id($post->ID), 83, 62, 39, 34, 28);
}
echo '<h3 class="a-medium a-prf-text">' . get_the_title();
echo '<br/>';
echo '<span class="a-prf-text__span">';
echo get_the_time('Y-m-d');
if (has_tag()) {
echo strip_tags(get_the_tag_list(' · ', ' · ', ''));
}
echo '</span>';
echo '</h3>';
echo '</a>';
}
?>
</section>
<?php
wp_reset_postdata();
}
示例11: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance)
{
$instance = wp_parse_args($instance, array('title' => '', 'post_type' => 'micro-projet'));
echo $args['before_widget'];
if ($instance['title']) {
/** This filter is documented in core/src/wp-includes/default-widgets.php */
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
}
// Show last micro project
$micro_project_query_args = array('post_type' => $instance['post_type'], 'posts_per_page' => 5);
if (is_singular()) {
$micro_project_query_args['post__not_in'] = array(get_the_ID());
}
$micro_project_query = new WP_Query($micro_project_query_args);
if ($micro_project_query->have_posts()) {
echo '<ul>';
while ($micro_project_query->have_posts()) {
$micro_project_query->the_post();
echo '<li>';
echo '<a href="' . get_the_permalink() . '">';
the_post_thumbnail('large');
the_title('<h3>', '</h3>');
echo '</a>';
echo '</li>';
}
echo '</ul>';
wp_reset_postdata();
}
echo $args['after_widget'];
}
示例12: zo_woo_share
/**
* WooCommerce Share Hook
*/
function zo_woo_share()
{
global $post;
?>
<ul class="social-list">
<li class="box"><a href="https://www.facebook.com/sharer/sharer.php?u=<?php
echo get_the_permalink();
?>
" onclick="javascript:void window.open(this.href,'','width=600,height=300,resizable=true,left=200px,top=200px');return false;"><i class="fa fa-facebook"></i></a></li>
<li class="box"><a href="https://twitter.com/intent/tweet?text=<?php
echo get_the_title();
?>
&url=<?php
echo get_the_permalink();
?>
" onclick="javascript:void window.open(this.href,'','width=600,height=300,resizable=true,left=200px,top=200px');return false;"><i class="fa fa-twitter"></i></a></li>
<li class="box"><a href="https://www.linkedin.com/cws/share?url=<?php
echo get_the_permalink();
?>
" onclick="javascript:void window.open(this.href,'','width=600,height=300,resizable=true,left=200px,top=200px');return false;"><i class="fa fa-linkedin"></i></a></li>
<li class="box"><a href="https://plus.google.com/share?url=<?php
echo get_the_permalink();
?>
" onclick="javascript:void window.open(this.href,'','width=600,height=300,resizable=true,left=200px,top=200px');return false;"><i class="fa fa-google-plus"></i></a></li>
<li class="box"><a href="http://pinterest.com/pin/create/button?url=<?php
echo get_the_permalink();
?>
" onclick="javascript:void window.open(this.href,'','width=600,height=300,resizable=true,left=200px,top=200px');return false;"><i class="fa fa-pinterest"></i></a></li>
</ul>
<?php
}
示例13: render
public function render($atts, $content = null)
{
$css = '';
extract(shortcode_atts(array('css' => ''), $atts));
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class($css, ' '));
$events = new WP_Query(array('post_type' => 'event', 'posts_per_page' => 4, 'order' => 'ASC', 'orderby' => 'event_when', 'meta_query' => array(array('key' => 'event_when', 'value' => current_time('timestamp'), 'compare' => '>'))));
$output = '';
if ($events->have_posts()) {
$output .= '<div class="event_list_module ' . $css_class . '">';
$output .= '<ul class="events_list clearfix">';
while ($events->have_posts()) {
$events->the_post();
$output .= '<li id="post-' . get_the_ID() . '" class="' . implode(' ', get_post_class()) . '">';
$output .= '<div class="event-content">';
$output .= '<div class="event-date_wrapper">';
$output .= '<div class="event_top"></div>';
$output .= '<div class="event-date">';
$output .= date('d', get_post_meta(get_the_ID(), 'event_when', true));
$output .= '<span>' . date('F', get_post_meta(get_the_ID(), 'event_when', true)) . '</span>';
$output .= '<div class="event-date-border"></div>';
$output .= '</div>';
$output .= '</div>';
$output .= '<h5><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h5>';
$output .= '<cite>' . get_post_meta(get_the_ID(), 'event_where', true) . '</cite>';
$output .= '<a href="' . get_the_permalink() . '" class="button">' . __('More Details', STM_DOMAIN) . '</a>';
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
$output .= '</div>';
}
wp_reset_query();
return $output;
}
示例14: widget
public function widget($args, $instance)
{
global $asgarosforum;
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
$title = !empty($instance['title']) ? $instance['title'] : __('Recent forum posts', 'asgaros-forum');
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
$number = !empty($instance['number']) ? absint($instance['number']) : 3;
if (!$number) {
$number = 3;
}
$target = !empty($instance['target']) ? $instance['target'] : '';
$posts = $asgarosforum->get_last_posts($number);
if (!empty($posts)) {
echo $args['before_widget'];
if ($title) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo '<ul class="asgarosforum-widget">';
foreach ($posts as $post) {
echo '<li>';
echo '<span class="post-link"><a href="' . $asgarosforum->get_widget_link($post->parent_id, $post->id, get_the_permalink($target)) . '">' . $asgarosforum->cut_string($post->name) . '</a></span>';
echo '<span class="post-author">' . __('by', 'asgaros-forum') . ' <b>' . $asgarosforum->get_username($post->author_id, false, true) . '</b></span>';
echo '<span class="post-date">' . sprintf(__('%s ago', 'asgaros-forum'), human_time_diff(strtotime($post->date), current_time('timestamp'))) . '</span>';
echo '</li>';
}
echo '</ul>';
echo $args['after_widget'];
}
}
示例15: widget
/**
* Outputs the HTML of the widget
*
* @param array $args
*
* @param array $instance
*
* @since 1.4
*/
public function widget($args, $instance)
{
extract($args);
if (is_single()) {
$fields = get_post_meta(get_the_ID(), 'read_more_links', true);
if ($fields) {
echo $args['before_widget'];
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
echo '<aside class="read-more-about-widget">';
foreach ($fields as $field) {
echo '<div class="story">';
if ($field['read_more_about_in_ex'] == 'internal') {
if (has_post_thumbnail($field['read_more_about_internal_link'])) {
echo '<div class="photo"><a href="' . get_the_permalink($field['read_more_about_internal_link']) . '">' . get_the_post_thumbnail($field['read_more_about_internal_link'], 'read-more') . '</a></div>';
}
echo '<h3 class="story-title"><a href="' . get_the_permalink($field['read_more_about_internal_link']) . '">' . get_the_title($field['read_more_about_internal_link']) . '</a></h3>';
} else {
echo '<h3 class="story-title"><a href="' . $field['read_more_about_link'] . '" target="_blank">' . $field['read_more_about_external_title'] . '</a></h3>';
}
echo '</div>';
}
echo '</aside>';
echo $args['after_widget'];
}
}
}