欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

wordpress外鏈 WordPress外鏈圖片燈箱效果

如何讓W(xué)ordPress自動對外鏈添加"nofollow"標(biāo)簽

這個實現(xiàn)起來還是挺簡單的,你可以使用以下代碼試試:

雙橋網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。成都創(chuàng)新互聯(lián)公司2013年開創(chuàng)至今到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司

//給外部鏈接加上nofollow標(biāo)簽

add_filter('the_content','the_content_nofollow',999);

function?the_content_nofollow($content)

{

preg_match_all('/a(.*?)href="(.*?)"(.*?)/',$content,$matches);

if($matches){

foreach($matches[2]?as?$val){

if(strpos($val,'://')!==false??strpos($val,home_url())===false??!preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){

$content=str_replace("href=\"$val\"",?"rel=\"nofollow\"?href=\"$val\"?",$content);

}

}

}

return?$content;

}

不過現(xiàn)在大部分WordPress站點都是直接將外鏈變成內(nèi)鏈來跳轉(zhuǎn)的,具體可以參考本站分享的《實測WordPress外鏈轉(zhuǎn)內(nèi)鏈跳轉(zhuǎn)地址為Base64加密地址》這篇文章。

wordpress寫文章過程中添加創(chuàng)建的相冊,如何給相冊里的每張圖片單獨添加外鏈?

圖片信息實際仍存儲在posts表中,post_type為attachment

后臺相冊編輯界面里沒有專門的欄目用于填寫外鏈地址,不過可以通過其他字段實現(xiàn)啊

如下圖,在alt text字段里填上該圖片的外鏈

接著,需要參考wp-includes/media.php文件里的gallery_shortcode函數(shù)來重構(gòu)gallery的輸出

在functions.php中添加代碼如下:

add_filter('post_gallery',?'my_post_gallery',?10,?3);

function?my_post_gallery(?$html?=?'',?$attr,?$instance?)?{

$post?=?get_post();

$html5?=?current_theme_supports(?'html5',?'gallery'?);

$atts?=?shortcode_atts(?array(

'order'??????=?'ASC',

'orderby'????=?'menu_order?ID',

'id'?????????=?$post???$post-ID?:?0,

'itemtag'????=?$html5???'figure'?????:?'dl',

'icontag'????=?$html5???'div'????????:?'dt',

'captiontag'?=?$html5???'figcaption'?:?'dd',

'columns'????=?3,

'size'???????=?'thumbnail',

'include'????=?'',

'exclude'????=?'',

'link'???????=?'none'

),?$attr,?'gallery'?);

$id?=?intval(?$atts['id']?);

if?(?!?empty(?$atts['include']?)?)?{

$_attachments?=?get_posts(?array(?'include'?=?$atts['include'],?'post_status'?=?'inherit',?'post_type'?=?'attachment',?'post_mime_type'?=?'image',?'order'?=?$atts['order'],?'orderby'?=?$atts['orderby']?)?);

$attachments?=?array();

foreach?(?$_attachments?as?$key?=?$val?)?{

$attachments[$val-ID]?=?$_attachments[$key];

}

}?elseif?(?!?empty(?$atts['exclude']?)?)?{

$attachments?=?get_children(?array(?'post_parent'?=?$id,?'exclude'?=?$atts['exclude'],?'post_status'?=?'inherit',?'post_type'?=?'attachment',?'post_mime_type'?=?'image',?'order'?=?$atts['order'],?'orderby'?=?$atts['orderby']?)?);

}?else?{

$attachments?=?get_children(?array(?'post_parent'?=?$id,?'post_status'?=?'inherit',?'post_type'?=?'attachment',?'post_mime_type'?=?'image',?'order'?=?$atts['order'],?'orderby'?=?$atts['orderby']?)?);

}

if?(?empty(?$attachments?)?)?{

return?'';

}

if?(?is_feed()?)?{

$output?=?"\n";

foreach?(?$attachments?as?$att_id?=?$attachment?)?{

$output?.=?wp_get_attachment_link(?$att_id,?$atts['size'],?true?)?.?"\n";

}

return?$output;

}

$itemtag?=?tag_escape(?$atts['itemtag']?);

$captiontag?=?tag_escape(?$atts['captiontag']?);

$icontag?=?tag_escape(?$atts['icontag']?);

$valid_tags?=?wp_kses_allowed_html(?'post'?);

if?(?!?isset(?$valid_tags[?$itemtag?]?)?)?{

$itemtag?=?'dl';

}

if?(?!?isset(?$valid_tags[?$captiontag?]?)?)?{

$captiontag?=?'dd';

}

if?(?!?isset(?$valid_tags[?$icontag?]?)?)?{

$icontag?=?'dt';

}

$columns?=?intval(?$atts['columns']?);

$itemwidth?=?$columns??0???floor(100/$columns)?:?100;

$float?=?is_rtl()???'right'?:?'left';

$selector?=?"gallery-{$instance}";

$gallery_style?=?'';

/**

*?Filters?whether?to?print?default?gallery?styles.

*

*?@since?3.1.0

*

*?@param?bool?$print?Whether?to?print?default?gallery?styles.

*????????????????????Defaults?to?false?if?the?theme?supports?HTML5?galleries.

*????????????????????Otherwise,?defaults?to?true.

*/

if?(?apply_filters(?'use_default_gallery_style',?!?$html5?)?)?{

$gallery_style?=?"

style?type='text/css'

#{$selector}?{

margin:?auto;

}

#{$selector}?.gallery-item?{

float:?{$float};

margin-top:?10px;

text-align:?center;

width:?{$itemwidth}%;

}

#{$selector}?img?{

border:?2px?solid?#cfcfcf;

}

#{$selector}?.gallery-caption?{

margin-left:?0;

}

/*?see?gallery_shortcode()?in?wp-includes/media.php?*/

/style\n\t\t";

}

$size_class?=?sanitize_html_class(?$atts['size']?);

$gallery_div?=?"div?id='$selector'?class='gallery?galleryid-{$id}?gallery-columns-{$columns}?gallery-size-{$size_class}'";

/**

*?Filters?the?default?gallery?shortcode?CSS?styles.

*

*?@since?2.5.0

*

*?@param?string?$gallery_style?Default?CSS?styles?and?opening?HTML?div?container

*??????????????????????????????for?the?gallery?shortcode?output.

*/

$output?=?apply_filters(?'gallery_style',?$gallery_style?.?$gallery_div?);

$i?=?0;

foreach?(?$attachments?as?$id?=?$attachment?)?{

$attr?=?(?trim(?$attachment-post_excerpt?)?)???array(?'aria-describedby'?=?"$selector-$id"?)?:?'';

if?(?!?empty(?$atts['link']?)??'file'?===?$atts['link']?)?{

$image_output?=?wp_get_attachment_link(?$id,?$atts['size'],?false,?false,?false,?$attr?);

}?elseif?(?!?empty(?$atts['link']?)??'none'?===?$atts['link']?)?{

$attr['alt']?=?get_the_title($post-ID);

$image_output?=?wp_get_attachment_image(?$id,?$atts['size'],?false,?$attr?);

$custom_link?=?trim(?strip_tags(?get_post_meta(?$id,?'_wp_attachment_image_alt',?true?)?)?);

$image_output?=?sprintf(?'a?href="%s"?title="%s"%sa',

$custom_link,

$attr['alt'],

$image_output

);

}?else?{

$image_output?=?wp_get_attachment_link(?$id,?$atts['size'],?true,?false,?false,?$attr?);

}

$image_meta??=?wp_get_attachment_metadata(?$id?);

$orientation?=?'';

if?(?isset(?$image_meta['height'],?$image_meta['width']?)?)?{

$orientation?=?(?$image_meta['height']??$image_meta['width']?)???'portrait'?:?'landscape';

}

$output?.=?"{$itemtag}?class='gallery-item'";

$output?.=?"

{$icontag}?class='gallery-icon?{$orientation}'

$image_output

/{$icontag}";

if?(?$captiontag??trim($attachment-post_excerpt)?)?{

$output?.=?"

{$captiontag}?class='wp-caption-text?gallery-caption'?id='$selector-$id'

"?.?wptexturize($attachment-post_excerpt)?.?"

/{$captiontag}";

}

$output?.=?"/{$itemtag}";

if?(?!?$html5??$columns??0??++$i?%?$columns?==?0?)?{

$output?.=?'br?style="clear:?both"?/';

}

}

if?(?!?$html5??$columns??0??$i?%?$columns?!==?0?)?{

$output?.=?"

br?style='clear:?both'?/";

}

$output?.=?"

/div\n";

return?$output;????

}

最后的效果:

請問你是如何實現(xiàn)wordpress特色圖片支持外鏈的呢

樓下鬼扯,由于安全方面的考慮,wordpress里是根本不支持外鏈圖片作為特色圖片的

真要實現(xiàn)這功能的話必須得自己改動下代碼了

首先在需要顯示特色圖像的地方(比如首頁,內(nèi)容頁)添加以下代碼:

?php

if ( $values = get_post_custom_values("thumb") ) { ?

a href="?php the_permalink() ?" title="?php the_title(); ?"img class="thumb" src="?php $values = get_post_custom_values("thumb"); echo $values[0]; ?" alt="?php the_title(); ?" //a

?php } else { ?

a href="?php the_permalink() ?" title="?php the_title(); ?"img class="thumb" src="/images/thumb.jpg" alt="?php the_title(); ?" //a

?php } ?

PS:上面代碼的css選擇器class="thumb"需要在css中自定義樣式。

接下來使用方法是:第一次的時候在自定義欄目里輸入新欄目名稱為thumb,然后在值里輸入縮略圖地址,絕對路徑或者相對路徑都可以。不輸入的話是不會有任何內(nèi)容出來的

方法2:安裝一個插件:“featured image from url”

如何在wordpress文章里批量插入圖片外鏈?

可以直接切換到文本格式,電腦端使用網(wǎng)頁編輯器或者文本編輯器批量編輯好連接圖片格式,然后復(fù)制粘貼即可

新聞標(biāo)題:wordpress外鏈 WordPress外鏈圖片燈箱效果
文章分享:http://chinadenli.net/article38/dogepsp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗網(wǎng)站設(shè)計公司、外貿(mào)建站、微信小程序網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作