2017-02-27 1 views
-1

나는 안돼서은 간단이 같은 워드 프레스 이미지 단축 코드를 생성 나를 도와주세요 클릭 할 때 동일한 원본 이미지.워드 프레스 간단한 이미지 단축 코드

검색을 시도했지만 기존 플러그인에서 찾을 수없는 경우 알려주십시오.

function.php 또는 그 밖의 다른 곳에서는 모든 사본을 붙여 넣으십시오.

답변

0
// Add Shortcode 
function img_shortcode($atts) 
{ 
    // Attributes 
    $atts = shortcode_atts(
     [ 
     'src' => '', 
     'link_to_img' => '', 
     ], $atts, 'img' 
    ); 

    $return = ''; 
    if ($atts['link_to_img'] == 'yes') 
    { 
     $return = '<a href="' . $atts['src'] . '"> 
        <img src="' . $atts['src'] . '"/> 
       </a>'; 
    } 
    else{ 
     $return = '<img src="' . $atts['src'] . '"/>'; 
    } 
    // Return HTML code 
    return $return; 
} 

add_shortcode('img', 'img_shortcode'); 

코드의 function.php 파일에가는 간단한 단축 코드를 사용하여 게시물과 페이지에 하나 개 이상의 이미지 갤러리를 추가하실 수 있습니다 활성 자식 테마 (또는 테마). 또는 모든 플러그인 PHP 파일에서.

USAGE
링크 :: PHP

echo do_shortcode('[img src="http://example.com/wp-content/uploads/2017/02/hello.jpg" link_to_img="no"]'); 

에서 링크 ::없이 편집기

[img src="http://example.com/wp-content/uploads/2017/02/hello.jpg" link_to_img="no"] 

에서 링크 ::와

PHP에서하지 않고 링크 : 희망이 도움이
[img src="http://example.com/wp-content/uploads/2017/02/hello.jpg" link_to_img="yes"] 

편집기

에서와
echo do_shortcode('[img src="http://example.com/wp-content/uploads/2017/02/hello.jpg" link_to_img="yes"]'); 

!

0

갤러리 기능은 워드 프레스가

[gallery ids="729,732,731,720"] 

enter link description here

+0

갤러리가 아닌 단순한 이미지를 원하지만 동일한 웹 사이트가 아니라 이미지 URL이 필요합니다. –

관련 문제