Using the Post’s Custom Fields Data In Sidebar
-
Basically, on my single.php I have my post laid out in the loop as normal.
I then include a seperate sidebar.php named sidebar-single.php as it will be different to the main index.php version.
In my actual post I set a custom field with some text I use to dynamically include a certain html file into the sidebar, depending on the post.
Say i set the custom field to “apples”, I want the code in the sidebar to automatically query the CURRENT post and look for the custom field and then output like a php include(/includes/apples.php)
I have done something similar inside the post loop where I can incorporate a banner depending on the custom field set, but I am struggling to get this working in the sidebar.
This is probably straight forward, but I am not much of a programmer to understand.
A simpler way to explain and do this would be to get the current single post title to be displayed in the sidebar outside of the loop.
Is this possible? Thanks in advance!
- The topic ‘Using the Post’s Custom Fields Data In Sidebar’ is closed to new replies.