Title: If Shortcode
Author: geomagas
Published: <strong>2014년 3월 2일</strong>
Last modified: 2024년 8월 2일

---

플러그인 검색

이 플러그인은 **최근 3개의 주요 워드프레스 출시와 시험 되지 않았습니다**. 워드프레스의
좀 더 최근 버전으로 이용할 때 더 이상 관리되지 않고 지원되지 않고 호환성 문제가 
있을 수 있습니다.

![](https://s.w.org/plugins/geopattern-icon/if-shortcode.svg)

# If Shortcode

 작성자: [geomagas](https://profiles.wordpress.org/geomagas/)

[다운로드](https://downloads.wordpress.org/plugin/if-shortcode.0.3.0.zip)

 * [세부사항](https://ko.wordpress.org/plugins/if-shortcode/#description)
 * [평가](https://ko.wordpress.org/plugins/if-shortcode/#reviews)
 *  [설치](https://ko.wordpress.org/plugins/if-shortcode/#installation)
 * [개발](https://ko.wordpress.org/plugins/if-shortcode/#developers)

 [지원](https://wordpress.org/support/plugin/if-shortcode/)

## 설명

This plugin provides an [if] shortcode to conditionally render content. The syntax
is the following:

    ```
    [if condition1 condition2=false condition3]{content}[/if]
    ```

Conditions are passed as attribute names. Multiple conditions evaluate to the result
of ORing all of them. In other words, if at least one condition evaluates to the
desired boolean result, {content} is rendered, otherwise it is discarded.
 Attribute
values determine if we want the condition to be true or false. A value of `'0'`,`'
false'`, `''` (the empty string), `'null'` or `'no'` means we expect the condition
to be false. Anything else, including the absense of a value, is interpreted as 
true.

For example, suppose that we want to include a sentence in a post, but only for 
anonymous visitors:

    ```
    [if is_user_logged_in=no]The Sentence.[/if]
    ```

It also provides an [else] shortcode and an [eitherway] one for use inside [if] 
blocks. [else] will render its content if the condition evaluates to false, and [
eitherway] will render its content regardless of the evaluation result.
 When used
outside an [if] block, these shortcodes behave as if the whole content is surrounded
by an [if] shortcode whose condition evaluates to true. In other words, an [else]
shortcode would not render any content, while a [eitherway] one would. You can use
as many of these shortcodes as you like in a single [if] block, which gives you 
the ability to do things like:

    ```
        - Am I logged in?
        [if is_user_logged_in]- Yes you are.
        [else]- No you are not.
        [/else][eitherway]- I'm sorry, what?
        [/eitherway]- I said YOU A-R-E LOGGED IN!!!
        [else]- YOU ARE NOT LOGGED IN!!! What's the matter with you?[/else][/if]
    ```

A multitude of conditions are supported out-of-the-box. The following evaluate to
the result of the corresponding [WordPress Conditional Tag](https://developer.wordpress.org/themes/basics/conditional-tags/),
using the no-parameter syntax:

    ```
        is_single
        is_singular
        is_page
        is_home
        is_front_page
        is_privacy_policy
        is_attachment
        is_category
        is_tag
        is_tax
        is_author
        is_archive
        is_year
        is_month
        is_date
        is_day
        is_time
        is_feed
        is_search
        is_sticky
        is_preview
        has_term
        has_excerpt
        comments_open
        pings_open
        is_404
        is_user_logged_in
        is_super_admin
        is_multi_author
        is_multisite
        is_main_site
        is_child_theme
    ```

For example, the evaluation of the `is_page` condition is equivalent to calling `
is_page()` with no parameter.

### Extending

The functionality of the plugin can be extended by other plugins, by means of adding
custom conditions through filters. To add a custom condition, a filter hook must
be defined in the following manner:

    ```
    add_filter($if_shortcode_filter_prefix.'my_condition','my_condition_evaluator');

    function my_condition_evaluator($value) {
        $evaluate=.... /* add your evaluation code here */
        return $evaluate;
    }
    ```

Then, you can use your custom condition like so:

    ```
    [if my_condition]{content}[/if]
    ```

A big thanks to M Miller for the [`normalize_empty_atts()`](http://wordpress.stackexchange.com/a/123073/39275)
function.

## 설치

Install the plugin using [the usual method described in the codex](https://wordpress.org/documentation/article/manage-plugins/#installing-plugins-1).

## 후기

![](https://secure.gravatar.com/avatar/a9ae342bd77a3304012103d22ffefbe1c20dd162c2b3b3e55b101fb328091a21?
s=60&d=retro&r=g)

### 󠀁[Lifesaver](https://wordpress.org/support/topic/lifesaver-17/)󠁿

 [jivyb](https://profiles.wordpress.org/jivyb/) 2016년 12월 23일

I needed to show a login form only to people not logged in. This little plugin was
perfect! Now I’m getting all kinds of ideas for what I can do with it. Thanks!

![](https://secure.gravatar.com/avatar/f83127a1d6743502aa12fa843bf9ca18326926a3b86a9a85d2e002e3e8256547?
s=60&d=retro&r=g)

### 󠀁[Just what I was looking for!](https://wordpress.org/support/topic/just-what-i-was-looking-for-260/)󠁿

 [McCarthy-Wood](https://profiles.wordpress.org/mccarthy-wood/) 2016년 9월 3일

Simple and clean to use!

![](https://secure.gravatar.com/avatar/adcf81f4f102f58505db81fc841246e3d939ab12ee7ed7ef178ecc061fb73346?
s=60&d=retro&r=g)

### 󠀁[Very easy to use](https://wordpress.org/support/topic/very-easy-to-use-173/)󠁿

 [J. Christopher Guritz](https://profiles.wordpress.org/guritz/) 2016년 9월 3일

If you are wanting to hide or show links or text based upon logged in state, author
or quite a few other “is” conditions this plugin is perfect. Thanks G J

 [ 모든 7 평가 읽기 ](https://wordpress.org/support/plugin/if-shortcode/reviews/)

## 기여자 & 개발자

“If Shortcode”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

 *   [ geomagas ](https://profiles.wordpress.org/geomagas/)

[자국어로 “If Shortcode”(을)를 번역하세요.](https://translate.wordpress.org/projects/wp-plugins/if-shortcode)

### 개발에 관심이 있으십니까?

[코드 탐색하기](https://plugins.trac.wordpress.org/browser/if-shortcode/)는, [SVN 저장소](https://plugins.svn.wordpress.org/if-shortcode/)
를 확인하시거나, [개발 기록](https://plugins.trac.wordpress.org/log/if-shortcode/)
을 [RSS](https://plugins.trac.wordpress.org/log/if-shortcode/?limit=100&mode=stop_on_copy&format=rss)
로 구독하세요.

## 변경이력

#### 0.3.0

 * Improvement: Refactored code for PHP 5.4+
 * Addition: Added some more tags

#### 0.2.1

 * Improvement: Removed unnecessary closure from line 87 ([thanks datacate](https://wordpress.org/support/topic/installation-error-84)!)

#### 0.2.0

 * Addition: [else] shortcode
 * Addition: [eitherway] shortcode

#### 0.1.0

 * First release.

## 기초

 *  버전 **0.3.0**
 *  최근 업데이트: **2년 전**
 *  활성화된 설치 **200+**
 *  워드프레스 버전 ** 3.0.1 또는 그 이상 **
 *  다음까지 시험됨: **6.6.7**
 *  PHP 버전 ** 5.4 또는 그 이상 **
 *  언어
 * [English (US)](https://wordpress.org/plugins/if-shortcode/)
 * 태그:
 * [conditional](https://ko.wordpress.org/plugins/tags/conditional/)[conditional-tags](https://ko.wordpress.org/plugins/tags/conditional-tags/)
   [else](https://ko.wordpress.org/plugins/tags/else/)[if](https://ko.wordpress.org/plugins/tags/if/)
   [shortcode](https://ko.wordpress.org/plugins/tags/shortcode/)
 *  [고급 보기](https://ko.wordpress.org/plugins/if-shortcode/advanced/)

## 평점

 별 5점 만점에 5점.

 *  [  6/5-별점 후기     ](https://wordpress.org/support/plugin/if-shortcode/reviews/?filter=5)
 *  [  0/4-별점 후기     ](https://wordpress.org/support/plugin/if-shortcode/reviews/?filter=4)
 *  [  0/3-별점 후기     ](https://wordpress.org/support/plugin/if-shortcode/reviews/?filter=3)
 *  [  0/2-별점 후기     ](https://wordpress.org/support/plugin/if-shortcode/reviews/?filter=2)
 *  [  0/1-별점 후기     ](https://wordpress.org/support/plugin/if-shortcode/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/if-shortcode/reviews/#new-post)

[모든  리뷰 보기](https://wordpress.org/support/plugin/if-shortcode/reviews/)

## 기여자

 *   [ geomagas ](https://profiles.wordpress.org/geomagas/)

## 지원

지난 2개월 동안 해결된 문제:

     1 중 0

 [지원 포럼 보기](https://wordpress.org/support/plugin/if-shortcode/)

## 기부

이 플러그인이 발전하도록 도우시겠습니까?

 [ 이 플러그인에 기부하기 ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5SD6XG9JD5TS8)