creating widgets that display different content based on conditionals.
-
hello,
i have a site that requires the same widgets to be displayed on most posts but with different content, for example a music player that is in the same place on all posts but the content of it changes depending on the post you are on.
i implemented a solution similar to this on joomla that enabled different header images to be displayed according to their Itemid (eg their ‘page number’). someone had suggested that i move the background to an inline style which used the code:
<div id="template_top" style="background:url('../images/header<?php echo JRequest:: getVar ('Itemid')?>.jpg') no-repeat">
then i had a folder full of header images that corresponded to the Itemid, ie 63.jpg, 54,jpg etc and if someone went to a page that had an Itemid of 63, then the 63.jpg header image was used.
so i am just wondering if something like this is possible in wordpress?
i have tried the widget logic plugin and that is awesome, but if i only used this as a solution i would end up having lots of widgets with conditional tags, as each post would need it’s own widget with a trigger of is_single(’17’) etc.
but what i need is one widget that contains code which generates different output depending on the post you are viewing.
i have a few different variables, but the first i am looking at is in the instance of a music player widget:
[jwplayer config="Widget Player" mediaid="219"]
here, the ‘mediaid’ would need to correspond to the post that was being viewed.
any ideas appreciated – thanks!
EDIT:
Looking into ‘Variable Sidebar Content‘ conditionals now.
- The topic ‘creating widgets that display different content based on conditionals.’ is closed to new replies.