get_pung()获取文章所有已经Ping过的URL

目录

描述

译文

检索文章中被引用的URL

原文

Retrieve URLs already pinged for a post.

get_pung() 描述

用法

<?php get_pung$post_id ?>

get_pung() 用法

参数

$post_id

(integer) (必填) Post ID.

默认值: None

get_pung() 参数

返回值

(array) 

Returns array of pinged URLs.

get_pung() 返回值

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
   <?php 
   $pinged_posts = get_pung( $post->ID );
   foreach ( $pinged_posts as $pinged_post ) :
           if (!empty($pinged_post) ) {
       echo 'Incoming Link: <a href="'.$pinged_post.'" rel="external">'.$pinged_post.'</a>';
           }
   endforeach; 
   ?>

get_pung() 示例

注意

get_pung() 注意

历史

添加于 版本: 1.5.0

get_pung() 历史

源文件

get_pung() 函数的代码位于 wp-includes/post.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve URLs already pinged for a post.
 *
 * @since 1.5.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $post_id Post ID.
 * @return array
 */
function get_pung( $post_id ) {
	global $wpdb;
	$pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
	$pung = trim($pung);
	$pung = preg_split('/s/', $pung);

	/**
	 * Filter the list of already-pinged URLs for the given post.
	 *
	 * @since 2.0.0
	 *
	 * @param array $pung Array of URLs already pinged for the given post.
	 */
	return apply_filters( 'get_pung', $pung );
}

get_pung() 源文件