WordPress获取固定链接标签:get_permalink
WordPress模板标签get_permalink用于获取文章的固定链接,也就是伪静态链接,需要用在The Loop主循环中,如果在主循环之外使用,需要传递文章ID或包含文章信息的对象。 get_permalink( int|WP_Post $post = 0, bool $leavename = false ) 函数参数$post …
WordPress模板标签get_permalink用于获取文章的固定链接,也就是伪静态链接,需要用在The Loop主循环中,如果在主循环之外使用,需要传递文章ID或包含文章信息的对象。 get_permalink( int|WP_Post $post = 0, bool $leavename = false ) 函数参数$post …
WordPress模板标签permalink_anchor输出一个ID为post-ID的空链接,通常用于跳转页面到特定位置,需要用在The Loop主循环中。 permalink_anchor( string $mode = 'id' ) 函数参数$mode 字符串值,默认值:id …
WordPress模板标签edit_bookmark_link输出编辑友情链接的链接,需要用在The Loop主循环中,如果在主循环之外使用,需要传递链接的ID。 edit_bookmark_link( string $link = '', string $before = '', string $after = '', int $bookmark = null ) 函数参数$link …
WordPress模板标签edit_tag_link用于输出编辑标签的链接,需要用在The Loop主循环中,如果在主循环之外使用,必须传递标签ID或包含标签信息的对象。 edit_tag_link( string $link = '', string $before = '', string $after = '', integer/object $tag = null ) 函数参数$link …
升级WordPress后,发现还有待更新项,查看是“WordPress一些翻译需要更新”,反复更新仍然提示,解决方法:修改php.ini,解除对函数scandir的禁用。 以LNMP一键包举例,编辑php.ini: …
WordPress模板标签edit_comment_link输出编辑评论的链接,需要用在The Loop主循环中。 edit_comment_link( string $text = null, string $before = '', string $after = '' ) 函数参数$text 字符串值,默认为空 链接锚文本 $before 字符串值,默认为空 …
WordPress是我这么多年来最喜欢的一款程序,不管大家如何抱怨它的臃肿,以及各种外部资源加载,我仍然热情的拥抱它,毕竟除了这两点,WordPress还是非常完美的。 事实上WordPress的这些小缺点也是可以解决的,关键就在于站长够不够勤奋,这里要说的是禁用Emoji表情的方法。 …
WordPress模板标签edit_post_link用于输出编辑文章的链接,必须用在The Loop主循环中。 edit_post_link( string $text = null, string $before = '', string $after = '', integer $id = 0, string $class = 'post-edit-link' ) 函数参数$text 字符串值,默认为空 链接的锚文本 …
网上流传的WordPress获取文章第一张图片作为缩略图的方法都是采用正则匹配抓取来实现的,代码如下: function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches[1][0]; if(empty($first_img)){ $first_img = '/images/default.jpg'; } return $first_img; } 有人说这种方式效率太低,所以我写了第二种方法,首先通过get_children()函数来获取文章的第一张图片ID: …
WordPress模板标签get_tag_link用于获取标签链接,该函数需要传递标签ID,以返回指定ID标签的链接。 get_tag_link( integer $tag ) 函数参数$tag 整数型,默认为空 指定标签ID,将返回该标签的链接。 …