With Galdget you can set up galleries in your posts or pages. Normally, they appear only on a post or page that they belong to.
Widgets are different, they appear on every post, page, category or other special page on your blog. Even on the “Page not profound” page.
But with [Galdget] and [Galdget plus+] WordPress plugins, you can set up a gallery in a widget that will appear on pages/posts of your choice.
To begin with, you should read how to set up the plugin here (free) or here (premium), if you haven’t done so.
The next task is to set up the URL list that is location-specific. We do this by using slugs, the last column in the URL list table. For example, to enlist pictures that will display only on this post, we use this post’s slug, how-to-set-up-a-widget-gallery-that-appears-only-on-one-page
. It is wise to designate a separate group to such items, to avoid mixing up with others.
Finally, we put the widget in the sidebar and set it up to have the group we have chosen in the previous step. In the sidebar to the left of this post, you are welcome to see the gallery with the title “On this post only”. What title says is true, you will not find it anywhere else on this blog.
There is a detailed description of how to perform the above two steps in another post, here. The only additions are the designated group and slug that you have to add to the URL list.
The examples follow:
- On one post/page only
- Only in category view
- Only on posts that belong to a category
- Only on tagged posts or in tag view
- On all but some categories
A single URL list is presented for all examples, with items as they should be set up to achieve desired behaviour, and with Group identifier corresponding to the example number. For each example, a widget should be set up with the group equal to the one in the URL list, which is not presented here as it is a straightforward task.
1. On one post
The post slug (or page slug) is human readable finishing part of the URL. For example, URL of this page is
https://plugins.unforget.rs/how-to-galdget/how-to-set-up-a-widget-gallery-that-appears-only-on-one-page/
and the slug is how-to-set-up-a-widget-gallery-that-appears-only-on-one-page
without any / before or after it.
First three items in the above URL list have the slug appears-only-on-one-page
and the widget with the group 1 (the same group as they are in) will be displayed only when page (or post) with the slug appears-only-on-one-page
is displayed. Since there are no other URLs with group 1 in the list, and also there are no URLs with group 0, the widget with the group 1 will not be displayed elsewhere.
2. Only in category view
Items 4 and 5 belong to the group 2 and have the slug set to cat.nature
. This means that the widget with group 2 will be displayed only in the category view for category with the slug nature
(and probably with the title “Nature
“). The “category view” means the display of the list of posts that belong to a selected category, so widget with the group 2 will not be displayed when a single post that belong to that category is displayed, only with the list of posts from that category.
Please note that the item 5 is dir://
which means folder on the web server which may (and should) contain a number of pictures, and we enlist it here as one item, which is handy.
3. Only on posts that belong to a category
Item 6 is dir://
, and it is designated with slug in.stories
which means that images from the corresponding folder will be displayed only with posts that belong to category stories
, only on single post display. So, widget with the group 3 will be visible only with posts from category stories
.
4. Only on tagged posts or in tag view
This is an interresting one. It should appear on tag view (similar to category view in 2.) or with tagged posts (similar to 3), which is two different places. We acomplish this by enlisting the URLs twice, once with tag.unbelievable
to ensure it is displayed “only” in the tag view for tag unbelievable
, and second time with as.unbelievable
to make it show up “only” with single posts tagged as unbelievable
.
Since this gallery is composed of two dir://
locations, for the group 4 we have four items in the URL list in total. We can see that they are marked as duplicates, but this is OK since the duplicate detection mechanisam does not read slugs, only URLs.
So, widget with group 4 will show up on both tag view for unbelievable
and with single posts tagged as unbelievable
, and nowhere else.
On all but some categories
All above mentioned slug designators can be inverted by prepending them with a minus sign. In our example we have a dir://
item that we want to display on all places except in several categories and with posts belonging to these categories. So, if categories to be “excluded” are skyline
and city
, we create the following slug:
-cat.skyline,-in.skyline,-cat.city,-in.city
Widget with group 5 will be displayed everywhere on the blog, except in:
- category view for category
skyline
- posts that belong to category
skyline
- category view for category
city
- posts that belong to category
city
More detail about setting up slugs in URL list setup can be found here or here.