Title: Shortcode Empty Paragraph Fix
Author: Johann Heyne
Published: <strong>2011 年 7 月 10 日</strong>
Last modified: 2016 年 1 月 22 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

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

# Shortcode Empty Paragraph Fix

 由 [Johann Heyne](https://profiles.wordpress.org/jonua/) 開發

[下載](https://downloads.wordpress.org/plugin/shortcode-empty-paragraph-fix.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/shortcode-empty-paragraph-fix/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/shortcode-empty-paragraph-fix/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/shortcode-empty-paragraph-fix/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/shortcode-empty-paragraph-fix/#developers)

 [技術支援](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/)

## 外掛說明

Fix [known issues](https://core.trac.wordpress.org/ticket/12061) when shortcodes
are embedded in a block of content that is filtered by wpautop.

#### for Theme Developers

If you are developing a theme to provide this on a marketplace, you better embed
the following code in your functions.php. This code filters only the shortcodes 
you defined. Otherwise you risk a failed review because the code in the plugin filters
content in general which may is not acceptet.

    ```
    function shortcode_empty_paragraph_fix( $content ) {

        // define your shortcodes to filter, '' filters all shortcodes
        $shortcodes = array( 'your_shortcode_1', 'your_shortcode_2' );

        foreach ( $shortcodes as $shortcode ) {

            $array = array (
                '<p>[' . $shortcode => '[' .$shortcode,
                '<p>[/' . $shortcode => '[/' .$shortcode,
                $shortcode . ']</p>' => $shortcode . ']',
                $shortcode . ']<br />' => $shortcode . ']'
            );

            $content = strtr( $content, $array );
        }

        return $content;
    }

    add_filter( 'the_content', 'shortcode_empty_paragraph_fix' );
    ```

Another solution that is acceptet at the envato (themeforest) marketplace comes 
from [bitfade](https://gist.github.com/bitfade/4555047).

## 安裝方式

 1. Upload folder `shortcode-empty-paragraph-fix` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

or

If you dont want to use a whole plugin to solve that bug, you can copy the code 
of the plugin file shortcode-empty-paragraph-fix.php into your theme function.php

## 常見問題集

  Installation Instructions

 1. Upload folder `shortcode-empty-paragraph-fix` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

or

If you dont want to use a whole plugin to solve that bug, you can copy the code 
of the plugin file shortcode-empty-paragraph-fix.php into your theme function.php

## 使用者評論

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

### 󠀁[Just what I needed.](https://wordpress.org/support/topic/just-what-i-needed-646/)󠁿

 [](https://profiles.wordpress.org/truetone/) 2017 年 10 月 5 日

Thanks for this fix. Worked great for me!

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

### 󠀁[Thanks! It solves my issue](https://wordpress.org/support/topic/thanks-it-solves-my-issue/)󠁿

 [Elisabeth Pointal](https://profiles.wordpress.org/epointal/) 2017 年 7 月 14 日

This simply plugin resolve the issue in mine. I added the function and filter to
my own plugin if it did not already exist.

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

### 󠀁[It’s work](https://wordpress.org/support/topic/its-work-11/)󠁿

 [studio-jt](https://profiles.wordpress.org/studiojt/) 2017 年 2 月 2 日

The standalone function work great , thank you

 [ 閱讀全部 21 則使用者評論 ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Shortcode Empty Paragraph Fix〉的開發相關工作。

參與者

 *   [ Johann Heyne ](https://profiles.wordpress.org/jonua/)

[將〈Shortcode Empty Paragraph Fix〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/shortcode-empty-paragraph-fix)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/shortcode-empty-paragraph-fix/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/shortcode-empty-paragraph-fix/)，
或透過 [RSS](https://plugins.trac.wordpress.org/log/shortcode-empty-paragraph-fix/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/shortcode-empty-paragraph-fix/)。

## 變更記錄

#### 0.1

 * Initial Release

#### 0.2

 * nicer code writing style

## 中繼資料

 *  版本 **0.2**
 *  最後更新 **10 年前**
 *  啟用安裝數 **800+**
 *  WordPress 版本需求 ** 2.5 或更新版本 **
 *  已測試相容的 WordPress 版本 **4.8.28**
 *  語言
 * [English (US)](https://wordpress.org/plugins/shortcode-empty-paragraph-fix/)
 * 標籤:
 * [fix](https://tw.wordpress.org/plugins/tags/fix/)[shortcode](https://tw.wordpress.org/plugins/tags/shortcode/)
 *  [進階檢視](https://tw.wordpress.org/plugins/shortcode-empty-paragraph-fix/advanced/)

## 評分

 4.8 星，滿分為 5 星

 *  [  19 個 5 星使用者評論     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=2)
 *  [  1 個 1 星使用者評論     ](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/?filter=1)

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

[查看全部使用者評論](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/reviews/)

## 參與者

 *   [ Johann Heyne ](https://profiles.wordpress.org/jonua/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/shortcode-empty-paragraph-fix/)