Title: Content Blocks (Custom Post Widget)
Author: Johan van der Wijk
Published: <strong>15. november 2010</strong>
Last modified: 27. januar 2026

---

Søk gjennom innstikk

![](https://ps.w.org/custom-post-widget/assets/banner-772x250.png?rev=2884166)

![](https://ps.w.org/custom-post-widget/assets/icon.svg?rev=2884166)

# Content Blocks (Custom Post Widget)

 Av [Johan van der Wijk](https://profiles.wordpress.org/vanderwijk/)

[Last ned](https://downloads.wordpress.org/plugin/custom-post-widget.3.4.1.zip)

 * [Detaljar](https://nn.wordpress.org/plugins/custom-post-widget/#description)
 * [Omtalar](https://nn.wordpress.org/plugins/custom-post-widget/#reviews)
 *  [Installasjon](https://nn.wordpress.org/plugins/custom-post-widget/#installation)
 * [Utvikling](https://nn.wordpress.org/plugins/custom-post-widget/#developers)

 [Hjelp](https://wordpress.org/support/plugin/custom-post-widget/)

## Skildring

The [Content Blocks](http://www.vanderwijk.com/wordpress/wordpress-custom-post-widget/?utm_source=wordpress&utm_medium=website&utm_campaign=custom_post_widget)
allows you to display the contents of a specific custom post in a widget on in the
content area using a shortcode.

Even though you could use the text widget that comes with the default WordPress 
install, this plugin has some major benefits:

 * The Content Blocks plugin enables users to **use the WYSIWYG editor** for editing
   the content and adding images.
 * If you are using the standard WordPress text widgets to display content on various
   areas of your template, this content can only be edited by users with administrator
   access. If you would like **non-administrator accounts to modify the widget content**,
   you can use this plugin to provide them access to the custom posts that provide
   the content for the widget areas.
 * You can even use the **featured image functionality** to display them in a widget.
 * The Content Blocks plugin is **compatible with the WPML** Multi-Language plugin
   and automatically shows the correct language in the widget area.
 * The Content Blocks can be included in posts and pages using the **built-in shortcode
   functionality**.

This plugin creates a «content_block» custom post type. You can choose to either
display the title on the page or use it to describe the contents and widget position
of the content block. Note that these content blocks can only be displayed in the
context of the page. I have added «public» => false to the custom post type which
means that it is not accessible outside the page context.

To add content to a widget, drag it to the required position in the sidebar and 
select the title of the custom post in the widget configuration.

**Includes the following translations:**

 * Swedish (sv_SE) by [Andreas Larsson](http://krokedil.se)
 * Spanish (es_ES) by [IBIDEM GROUP](https://www.ibidemgroup.com)
 * Portuguese (pt_BR) by Ronaldo Chevalier
 * Polish (pl_PL) by Kuba Skublicki
 * Dutch (nl_NL) by [Johan van der Wijk](https://vanderwijk.nl)
 * Czech (cs_CZ) by [Martin Kucera](http://jsemweb.cz/)

[More translations are very welcome!](https://translate.wordpress.org/projects/wp-plugins/custom-post-widget)

## Skjermbilete

 * [[
 * After activating the plugin a new post type called «Content Blocks» is added.
 * [[
 * The widget has a select box to choose the content block. Click on the «Edit Content
   Block» link to edit the selected Content Block custom post.
 * [[
 * You will find a button above the WYSIWYG editor that allows you to insert the
   content block using the shortcode.
 * [[
 * After clicking the «Add Content Block» button you can select a content block 
   and insert the shortcode in the content area.

## Installasjon

 1. First you will have to upload the plugin to the `/wp-content/plugins/` folder.
 2. Then activate the plugin in the plugin panel.
     You will see that a new custom post
    type has been added called Content Block.
 3. Type some content for the widget. You can choose to either use the title to describe
    the content on the page, or to display it. Check «Show Post Title» to display the
    title on the page.
 4. Go to «Appearance» > «Widgets» and drag the Content Block widget to the required
    position in the sidebar.
 5. Select a Content Block from the drop-down list.
 6. Check the «Show Post Title» checkbox if you would like to display the title of 
    your Content Block
 7. If you are experiencing issues with content being added automatically to your posts(
    Social media sharing buttons for instance), check the «Do not apply content filters»
    checkbox. Use this with caution!
 8. Click save.

## Vanlege spm.

### Why can’t I use the default text-widget?

Of course you can always use the default text widget, but if you prefer to use the
WYSIWYG editor or if you have multiple editors and you don’t want to give them administrator
rights, it is recommended to use this plugin.

### How can I show the content bock on a specific page?

It is recommended to install the [Widget Logic](https://wordpress.org/extend/plugins/widget-logic/)
plugin, this will give you complete flexibility on widget placement.

### How can I display the featured image in the widget?

This plugin has built-in support for the featured image functionality on the edit
screen. Note that featured image will not be resized, so you will have to make sure
it is the right size when uploading or restrict the image size via the stylesheet.

### My social sharing plugin adds buttons to all the Content Block areas

If your social media sharing plugin adds buttons to the widget areas you could check
the «Do not apply content filters» checkbox. Note that when this is done, WordPress
will also stop adding paragraph tags to your text, so use this setting with caution.
It is much better to ask the developer of the social media sharing buttons plugin
to correctly use the content filters (see http://pippinsplugins.com/playing-nice-
with-the-content-filter/ for more information on this). If you are embedding your
content block with the shortcode, add the following: `suppress_content_filters="
yes"`

### The featured image is not displayed when using the shortcode

Currently the shortcode function only outputs the post content and title of the 
content block, future support for displaying the attached featured image is being
considered.

### Can I change the output of the content blocks?

Yes, you can create your own template for the content blocks, you can do so by adding
a file named custom-post-widget.php to your theme folder. More information about
this can be found in this [support topic](https://wordpress.org/support/topic/patch-custom-widget-frontends/?replies=1)

In these Gists you can find examples of templates for [shortcodes](https://gist.github.com/vanderwijk/18acd549b099253eb222daf7757f1689)
and for [widgets](https://gist.github.com/vanderwijk/a396171845cf923c23d09dddb4269fb1)

### I have a feature request

Please post your feature request on [the support forum](https://wordpress.org/support/plugin/custom-post-widget)

These new features are on the to-do list:

 * Display the content block featured image when using the shortcode
 * Front-end editing of the content blocks
 * Visual Composer integration
 * Show the shortcode on the «View all Content Blocks» list view

### How can I make advanced changes to the widget layout?

You can create your own widget template and upload this to your theme folder. See
[this support topic](https://wordpress.org/support/topic/patch-custom-widget-frontends?replies=1)
for more information about this feature.

### Can I make the post type public?

You can make the post type public by adding the following code to your theme’s functions.
php file:
 function filter_content_block_init() { $content_block_public = true; 
return $content_block_public; } add_filter(«content_block_post_type»,’filter_content_block_init»);

Alternatively you can use [this third-party plugin](http://demomentsomtres.com/english/wordpress-plugins/demomentsomtres-wpbakery-visual-composer-custom-post-widget/).

### Post ID’s confuse me, can I use the post slug for embedding a content block?

Yes, v2.6 now gives you the option to use the content block’s url slug in the shortcode.
Use the following syntax for doing this: `[content_block slug=my-content-block]`.

Note that if you ever change the slug of a content block, the embedding no longer
works. Therefore I recommend using the post ID instead (which never changes).

### Can I specify a custom class for the embedded content blocks?

By default the shortcode adds a div around the content block with the class content_block.
If you like, you can change this class by adding it to the shortcode: [content_block
id=198 slug=our-wordpress-plugins class=my-class]

### How can I embed a content block in my template file using php code?

You can use the do_shortcode function for this: `echo do_shortcode('[content_block
id= ]');`

See https://codex.wordpress.org/Function_Reference/do_shortcode for more information
on this function.

### The plugin is not working for me

Please create a support topic in the forum: https://wordpress.org/support/plugin/
custom-post-widget

### I love your plugin! What can I do to help?

Creating and supporting this plugin takes up a lot of my free time, therefore I 
would highly appreciate it if you could take a couple of minutes to [write a review](https://wordpress.org/support/view/plugin-reviews/custom-post-widget).
This will help other WordPress users to start using this plugin and keep me motivated
to maintain and support it. Also, if you have a twitter, Facebook or Google+ account,
it would be fantastic if you could share the link to this plugin!

## Omtalar

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

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-10831/)󠁿

 [becaneweb](https://profiles.wordpress.org/becaneweb/) 17. september 2025

thanks, good job !

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

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-10559/)󠁿

 [Anonymous User](https://profiles.wordpress.org/anonymized-20565804/) 29. oktober
2024

Brilliantly useful plugin.

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

### 󠀁[Brilliant](https://wordpress.org/support/topic/brilliant-1642/)󠁿

 [Henrik](https://profiles.wordpress.org/heinohund/) 7. september 2024

Easy use, brilliant plugin

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

### 󠀁[Helpful CM tool](https://wordpress.org/support/topic/helpful-cm-tool/)󠁿

 [jbleys](https://profiles.wordpress.org/jbleys/) 26. oktober 2023

Out of the box this tool is great to manage content. But the ability to use your
own template part is where its versatility shines and allows for endless possibilities.
Thanks for a great plugin.

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

### 󠀁[Very useful! I was writing my own when I found this.](https://wordpress.org/support/topic/very-useful-i-was-writing-my-own-when-i-found-this/)󠁿

 [ghartwig](https://profiles.wordpress.org/ghartwig/) 24. juli 2023

I can finally have canned text and place it on more than one page without having
to duplicate it. Great for temporary notices, or any reused text.

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

### 󠀁[Compatible with elementor](https://wordpress.org/support/topic/compatible-with-elementor-18/)󠁿

 [sw38](https://profiles.wordpress.org/swd38/) 28. mai 2023

I can use this plugin with Elementor. Very good!

 [ Les alle 80 omtalar ](https://wordpress.org/support/plugin/custom-post-widget/reviews/)

## Bidragsytarar og utviklarar

“Content Blocks (Custom Post Widget)” is open source software. The following people
have contributed to this plugin.

Contributors

 *   [ Johan van der Wijk ](https://profiles.wordpress.org/vanderwijk/)

“Content Blocks (Custom Post Widget)” er omsett til 11 språk. Takk til [omsetjarane](https://translate.wordpress.org/projects/wp-plugins/custom-post-widget/contributors)
for bidraga deira.

[Omset “Content Blocks (Custom Post Widget)” til ditt eige språk.](https://translate.wordpress.org/projects/wp-plugins/custom-post-widget)

### Interested in development?

[Les kjeldekoden](https://plugins.trac.wordpress.org/browser/custom-post-widget/),
sjekk [SVN-lageret](https://plugins.svn.wordpress.org/custom-post-widget/) eller
abonner på [utviklingsloggen](https://plugins.trac.wordpress.org/log/custom-post-widget/)
med [RSS](https://plugins.trac.wordpress.org/log/custom-post-widget/?limit=100&mode=stop_on_copy&format=rss).

## Endringslogg

#### 3.4.1

Security fix: Added allowlist validation for the shortcode markup attribute to prevent
XSS attacks (CVE-2026-0894).

#### 3.3.9

WP 6.9 compatibility tested and confirmed

#### 3.3.8

WP 6.8 compatibility tested and confirmed

#### 3.3.7

WP 6.7 compatibility tested and confirmed

#### 3.3.6

Security fix for potential use of script tags in the title.

#### 3.3.5

Security fix for potential use of script tags in the title. Added output sanitization.

#### 3.3.3

WP 6.6 compatibility tested and confirmed

#### 3.3.2

Changed constants for theme folder to use get_stylesheet_directory() and get_template_directory().

#### 3.3.1

Changes to the shortcode function that allows for loading of a custom template file
and the function that allows you to use a custom tag to wrap the content block and
title. Note that this could cause issues if you are using a template that is not
in your template folder.

#### 3.3.0

WP 6.5 compatibility tested and confirmed

#### 3.2.9

Fix for stripped html tags when using the suppress_content_filters option on the
shortcode. As reported in the support forums: https://wordpress.org/support/topic/
html-content-now-showing-as-text/

#### 3.2.8

Added input sanitization on the shortcode arguments to prevent potential security
issues.

#### 3.2.7

Fix for PHP 8.1 notice passing null to parameter #1 ($datetime) of type string is
deprecated

#### 3.2.6

WP 6.3 compatibility tested and confirmed

#### 3.2.2

WP 5.8 compatibility tested and confirmed

#### 3.2.1

Bugfix for notice in shortcode.php

#### 3.2

Thanks to Bruce from [Ingeni Web Solutions](https://ingeni.net/) it is now possible
to use your own template for embedding the custom post shortcode.

#### 3.1.6

Compatibility testing. Also tested on PHP8 and found no issues.

#### 3.1.5

Spanish translation added and readme.txt file updates.

#### 3.1.4

Minor bugfix and upgrade for the clipboard.js script. Thanks to https://wordpress.
org/support/users/vikaspandeyd/ for reporting this!

#### 3.1

You can now use a custom html tag to wrap the content block when using a shortcode.
See https://wordpress.org/support/topic/add-support-for-spans/ for more information
and usage.

#### 3.0.4

Added Gutenberg compatibility for editing content blocks. This is for editing content
blocks only. There is no block button yet for inserting a content block in the Gutenberg
editor, so you will have to choose the «Shortcode» widget and insert your content
block shortcode there.

#### 3.0.3

Added the option to show the featured image in when using the shortcode. Add featured_image
=yes to the shortcode to show it: `[content_block featured_image=yes]`. By default
the medium image size is displayed, you can change it like this: `[content_block
featured_image=yes featured_image_size=full]`.

#### 3.0.2

Tested for WordPress 4.8 compatibility.

#### 3.0.1

Added html sanitizing to the Content Block post titles. Thanks to @palpatine1976
for bringing this to my attention.

#### 3.0

Renamed the plugin to Content Blocks to better reflect the purpose.

#### 2.9.2

Minor layout change to the Shortcodes meta box.

#### 2.9

Removed the admin notice, added donation link to plugin overview page. Shortcodes
are now displayed on the content block edit screen, thanks to [Remkus](https://forsite.media/)
for suggesting this feature.

#### 2.8.5

Fix for minor compatibility issue when using the Slider Revolution plugin

#### 2.8.4

You can now optionally show the post title when using the shortcode by adding `title
=yes` to the shortcode

#### 2.8.3

Added Hebrew translation as provided by Daniel Cohen Gindi

#### 2.8.1

Updated language files.

#### 2.8

Added the option to suppress the content filters when using the shortcode. Thanks
to adelval for providing the code, see https://wordpress.org/support/topic/add-option-
to-not-apply-content-filters-in-shortcode?replies=4

#### 2.7.9

Changed method for creating the widget in preparation of PHP7 support.

#### 2.7.7

Added Czech translation.

#### 2.7.6

Added Italian translation.

#### 2.7.5

Updated branding and language files.

#### 2.7.4

The shortcode now includes the slug of the content block (which is still optional),
see https://wordpress.org/support/topic/shortcodes-using-slug-name-rather-than-id
for more information on this.

#### 2.7.2

The post status is now used for displaying the content blocks in the widget areas,
only published content blocks are now displayed. Thanks to tmbdesign.co.uk for suggesting
this change.

#### 2.7

Added dismissable support notification.

#### 2.6

Added the possibility for using the content block slug in the shortcode.

#### 2.5.7

Changed the way the button above the content editor is inserted. For background 
see: https://wordpress.org/support/topic/soliloquy-conflict-1?replies=2

#### 2.5.3

Added filter to «public» value of the content_block post type to make it possible
to use the Visual Composer plugin. See support topic: https://wordpress.org/support/
topic/make-post-type-public

#### 2.5.2

Changed require to require_once in custom-post-widget.php to solve a possible issue
reported by John Sundberg.
 Updated SE translation files as provided by Andreas 
Larsson.

#### 2.5

Added «Content Block Information» to overview page, updated styling to reflect new
3.8 interface and rewrote javaScript code for inserting shortcode tag

#### 2.4.5

2.4.5 javaScript fix for inserting shortcode tag

#### 2.4.4

Added unique ID to each content block that is inserted using the shortcode functionality

#### 2.4.3

Changed the way the shortcode button above the editor is called.

#### 2.4

You can now add a description to the content block to make it easier for content
editors to find out where the block is displayed on the site. Thanks to Andreas 
Larsson the plugin now includes a Swedish translation.

#### 2.3.5

Added the option to use your own widget template file as suggested by flynsarmy.
See https://wordpress.org/support/topic/patch-custom-widget-frontends?replies=1 
for more information.

#### 2.3.4

Added pt_BR translation files as kindly provided by Ronaldo Chevalier.

#### 2.3.2

Removed hardcoded plugins folder path

#### 2.3.1

Removed call to CUSTOM_POST_WIDGET_DIR

#### 2.3

Various bugfixes and improvements.

#### 2.0.3

Replaced the deprecated `media_buttons_context` filter with `media_buttons`. Thanks
to Baptiste Gaillard for letting me know about this.

#### 2.0.2

Small fix for issue with the css filepath of the editor icon. Thanks to user zudobug
for reporting this issue.

#### 2.0.1

Updated Dutch translation file.

#### 2.0

Fix for bug caused by the «Advanced Custom Fields» plugin. Thanks to creativexperience
for troubleshooting this issue.
 Cleanup of lightbox popup, changed all instances
of query_posts to get_post and get_posts. Support for featured image in custom post
widget area. Changed shortcode button to reflect the new admin style of WordPress
version 3.5.

#### 1.9.8

Fix for error when using shortcode with the WPML plugin

#### 1.9.7

Added featured image support and now using query_posts instead of get_post

#### 1.9.6

Fixed debug notices when dragging a new content block to the widget areas and removed
the add content block shortcode from the content block editing screen.

#### 1.9.5

Added the option to disable apply_filters on the content to prevent issues with 
misbehaving plugins. I would have rather not added this, but it appears many plugin
developers do not know how to properly use filters (see http://pippinsplugins.com/
playing-nice-with-the-content-filter/).

#### 1.9.4

Corrected a minor bug regarding translation strings.

#### 1.9.3

Minor bugfix and added the French translation which was created by Alexandre Simard.

#### 1.9.2

Now includes Polish language files as created by Kuba Skublicki.

#### 1.9

The content blocks can now be translated using the WPML plugin, thanks to Jonathan
Liuti.
 Thanks to Vitaliy Kaplya (https://vitaliikaplia.com/) a Russian translation
has been added to the plugin.

#### 1.8.6

Minor bugfix for edit link in widget.

#### 1.8.5

This release is to fix an issue with the WordPress plugin repository.

#### 1.8.4

Added edit content block link to the widget editor and changed the «view content
block» message to include a «manage widgets» link. The «Draft» and «Preview» buttons
are now hidden via CSS, hopefully this will soon be default WordPress behaviour (
see related ticket: https://core.trac.wordpress.org/ticket/18956).
 Thanks to Julian
Gardner-Hobbs for requesting this functionality.

#### 1.8.3 -> rolled-back because of some reported issues with social media icons being added to the widget areas

The widget now emulates the $post loop. This means you can now make use of WordPress
functionality such as inserting a [gallery]. Thanks to Jari Pennanen for providing
the code.

#### 1.8.2

Updated German translation and various bugfixes.

#### 1.8

Added a button above to content editor to make it easier to add the shortcode (no
need for looking up the id).

#### 1.7

This release fixes all the debug error messages Yoast discovered when [reviewing this plugin](http://yoast.com/wp-plugin-review/custom-post-widget/).
As requested by Tony Allsopp the option of using the shortcode [content_block id
= ] to pull in the content of a content block in a page or post has been added.

#### 1.6

The Custom Post Widget plugin is now using the more efficient get_post instead of
query_posts to display the content block on the page. A code example for this change
has been graciously provided by Paul de Wouters.

#### 1.5

Thanks to Caspar Huebinger the plugin now has its own icon and as requested by Stephen
James the author field has been added to the Content Block edit screen.

#### 1.4

The plugin has been translated into Dutch and German. Hat tip: Caspar Hübinger –
glueckpress.com

#### 1.3

Now the title of the content block is displayed in the admin interface to make it
easy to manage the widgets.

#### 1.2.1

The widget title now uses $before_title and $after_title to generate the appropriate
tags to display it on the page. Hat tip: Etienne Proust.

#### 1.2

Added a checkbox in the widget to make it possible to show the custom post title
in the widget area

#### 1.1.1

Added showposts=-1 to the post query to display more than 10 custom posts in the
widget configuration select box.

#### 1.1

Fixed screenshots for plugin directory

#### 1.0

First release

## Om

 *  Version **3.4.1**
 *  Last updated **3 månader sidan**
 *  Active installations **10 000+**
 *  WordPress version ** 4.6 eller nyare **
 *  Tested up to **6.9.4**
 *  Languages
 * [Chinese (Taiwan)](https://tw.wordpress.org/plugins/custom-post-widget/), [Czech](https://cs.wordpress.org/plugins/custom-post-widget/),
   [Dutch](https://nl.wordpress.org/plugins/custom-post-widget/), [English (US)](https://wordpress.org/plugins/custom-post-widget/),
   [French (France)](https://fr.wordpress.org/plugins/custom-post-widget/), [Hebrew](https://he.wordpress.org/plugins/custom-post-widget/),
   [Polish](https://pl.wordpress.org/plugins/custom-post-widget/), [Portuguese (Brazil)](https://br.wordpress.org/plugins/custom-post-widget/),
   [Russian](https://ru.wordpress.org/plugins/custom-post-widget/), [Spanish (Chile)](https://cl.wordpress.org/plugins/custom-post-widget/),
   [Spanish (Spain)](https://es.wordpress.org/plugins/custom-post-widget/) og [Swedish](https://sv.wordpress.org/plugins/custom-post-widget/).
 *  [Omset til språket ditt](https://translate.wordpress.org/projects/wp-plugins/custom-post-widget)
 * Tags
 * [block](https://nn.wordpress.org/plugins/tags/block/)[content block](https://nn.wordpress.org/plugins/tags/content-block/)
   [custom post](https://nn.wordpress.org/plugins/tags/custom-post/)[shortcode](https://nn.wordpress.org/plugins/tags/shortcode/)
   [widget](https://nn.wordpress.org/plugins/tags/widget/)
 *  [Avansert vising](https://nn.wordpress.org/plugins/custom-post-widget/advanced/)

## Vurderingar

 4.9 out of 5 stars.

 *  [  75 5-star reviews     ](https://wordpress.org/support/plugin/custom-post-widget/reviews/?filter=5)
 *  [  4 4-star reviews     ](https://wordpress.org/support/plugin/custom-post-widget/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/custom-post-widget/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/custom-post-widget/reviews/?filter=2)
 *  [  1 1-star review     ](https://wordpress.org/support/plugin/custom-post-widget/reviews/?filter=1)

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

[See all reviews](https://wordpress.org/support/plugin/custom-post-widget/reviews/)

## Contributors

 *   [ Johan van der Wijk ](https://profiles.wordpress.org/vanderwijk/)

## Hjelp

Har du noko å seia? Treng du hjelp?

 [Sjå hjelpeforumet](https://wordpress.org/support/plugin/custom-post-widget/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://www.paypal.me/vanderwijk)