Title: Gallery Shortcode Style to Head
Author: Matt Martz
Published: <strong>2008 年 8 月 27 日</strong>
Last modified: 2015 年 4 月 2 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/gallery-shortcode-style-to-head.svg)

# Gallery Shortcode Style to Head

 作者：[Matt Martz](https://profiles.wordpress.org/sivel/)

[下载](https://downloads.wordpress.org/plugin/gallery-shortcode-style-to-head.2.4.zip)

 * [详情](https://cn.wordpress.org/plugins/gallery-shortcode-style-to-head/#description)
 * [评价](https://cn.wordpress.org/plugins/gallery-shortcode-style-to-head/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/gallery-shortcode-style-to-head/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/gallery-shortcode-style-to-head/#developers)

 [支持](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/)

## 描述

Moves the gallery shortcode styles to the head so it doesn’t break XHTML
 validation;
allows disabling or modifying the default gallery styles.

By default when using the WordPress gallery, the styles are placed into the
 post
content which breaks XHTML validation. This plugin moves the style into the head
of the page using a look-ahead to determine if the [gallery] shortcode is used in
any posts.

This plugin also gives you the option to modify the default gallery style
 CSS or
disable the gallery styles entirely (so you can control it from your template CSS
files).

This plugin uses ideas recommended in a patch located at
 https://trac.wordpress.
org/attachment/ticket/6380/6380-style.diff

Special thanks to
 * The original author: Matt Martz, http://sivel.net * Serbo-Croatian(
sr_RS) translation: Borisa Djuraskovic, http://www.webhostinghub.com * Spanish (
es_ES) translation: Ogi Djuraskovic, http://www.webhostinghub.com/

## 屏幕截图

[⌊Plugin settings (under Admin > Settings > Media).⌉⌊Plugin settings (under Admin
> Settings > Media).⌉[

Plugin settings (under Admin > Settings > Media).

## 安装

Installation is just like any other WordPress plugin:

 1. Upload the ‘gallery-shortcode-style-to-head’ folder to the ‘/wp-content/plugins/’
    directory.
 2. Activate the plugin through the ‘Plugins’ menu in WordPress.

Immediately after installation, your galleries should pass W3C XHTML validation.
You can make further adjustments under Admin > Settings > Media.

## 常见问题

  How do I make the WP galleries XHTML compliant?

 1. Just activate the plugin. Nothing else is required.

  How do I adjust the default gallery CSS styles?

 1. In WP admin, go to Settings > Media.
 2. Scroll down to “Modify gallery CSS style.’”
 3. Adjust to your liking!
 4. Click “Save Changes.”

  How do I disable the CSS styles (so I can control the CSS in my template)?

 1. In WP admin, go to Settings > Media.
 2. Scroll down to “Disable gallery CSS in ‘head.’”
 3. Check the box.
 4. Click “Save Changes.”

  How do I reset the gallery CSS styles to default?

 1. In WP admin, go to Settings > Media.
 2. Un-check the setting for “Disable gallery CSS in ‘head’.”
 3. Clear everything in the “Modify gallery CSS style” text field (so it’s totally 
    empty).
 4. Click “Save Changes.” The styles will be reset to default.

## 评价

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

### 󠀁[Works well](https://wordpress.org/support/topic/works-well-1267/)󠁿

 [certainlyakey](https://profiles.wordpress.org/certainlyakey/) 2018 年 1 月 18 
日

Works well and is quite unobtrusive. Not needed since WP 3.9 introduced HTML5 based
galleries.

 [ 阅读所有1条评价 ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/)

## 贡献者及开发者

「Gallery Shortcode Style to Head」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ Matt Martz ](https://profiles.wordpress.org/sivel/)
 *   [ achmafooma ](https://profiles.wordpress.org/achmafooma/)

[帮助将「Gallery Shortcode Style to Head」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/gallery-shortcode-style-to-head)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/gallery-shortcode-style-to-head/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/gallery-shortcode-style-to-head/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/gallery-shortcode-style-to-head/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/gallery-shortcode-style-to-head/)。

## 更新日志

#### 2.4 (2015-03-02):

 * Plugin is now translateable.
 * Code cleanup and support for latest WordPress.
 * Serbo-Croatian (sr_RS) translation by Borisa Djuraskovic, http://www.webhostinghub.
   com.
 * Spanish (es_ES) translation by Ogi Djuraskovic, http://www.webhostinghub.com/.

#### 2.3 (2013-03-08):

 * Corrected ‘undefined varibale’ notice and RTL language detection.
 * Now requires WordPress 3.0 or higher.

#### 2.2 (2012-12-11):

 * Support for WordPress 3.5 and its improved galleries.

#### 2.1 (2011-01-15):

 * Removed clearing br tags in galleries (replaced with clearing div tags).
 * Corrected bug that threw a cryptic error on the media page for some users.
 * Support for WordPress 3.1; now requires WordPress 2.9 or higher.

#### 2.0 (2010-05-02):

 * New gallery style settings on the Admin > Settings > Media page.
 * Ability to modify the default gallery styles.
 * Ability to disable the default styles entirely (so you can style the gallery 
   in your template CSS).
 * Support for WordPress 3.0; now requires WordPress 2.7 or higher.

#### 1.3 (2010-02-09):

 * Re-Sync with WordPress 2.9 gallery code for support of the new ‘include’ and ‘
   exclude’ options.

#### 1.2 (2009-09-20):

 * Corrected function of ‘Link thumbnails to…’ setting on galleries when this plugin
   is enabled.

#### 1.1 (2008-09-22):

 * Added filter so that the default style can be overridden.

#### 1.0 (2008-08-27):

 * Initial Public Release

## 额外信息

 *  版本 **2.4**
 *  最后更新：**12 年前**
 *  活跃安装数量 **100+**
 *  WordPress 版本 ** 3.3 或更高版本 **
 *  已测试的最高版本为 **4.1.42**
 *  语言
 * [English (US)](https://wordpress.org/plugins/gallery-shortcode-style-to-head/)
 * 标签
 * [css](https://cn.wordpress.org/plugins/tags/css/)[gallery](https://cn.wordpress.org/plugins/tags/gallery/)
   [shortcode](https://cn.wordpress.org/plugins/tags/shortcode/)[style](https://cn.wordpress.org/plugins/tags/style/)
   [xhtml](https://cn.wordpress.org/plugins/tags/xhtml/)
 *  [高级视图](https://cn.wordpress.org/plugins/gallery-shortcode-style-to-head/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  1 条 5 星评价     ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/?filter=1)

[您的评价](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/reviews/)

## 贡献者

 *   [ Matt Martz ](https://profiles.wordpress.org/sivel/)
 *   [ achmafooma ](https://profiles.wordpress.org/achmafooma/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/gallery-shortcode-style-to-head/)