tags:

views:

38

answers:

1

Hi-

I am somewhat new to both Wordpress and PHP, and I wanted to get advice on the best way to tackle my problem as I have had little luck doing it successfully so far.

There are two jobs I want to handle:

First of all, I want to have a conditional include on my home page that does the following;

Find a custom post type home_content (only ever going to be 1 post, which is ID 76 - if that helps) Display 3 custom fields from that post... the values for today_on front_widget_a & front_widget_b

(I guess a secondary question would be - can I even pass shortcode through a custom field, because that's what those widgets are being generated from, is shortcode from a plug-in)

That's pretty much it. I've tried various combination of get_posts and get_post_meta without much success. Either I get some syntax errors I can't figure out (and trust me I've combed my code many times for missing semi-colons and the like). That or I get a result that makes no sense.

The second one is a bit more difficult.

Basically trying to turn a part of my Wordpress into a bit of a CMS-style feature. Basically, I have 2 additional custom post types, one called tag_page_layout and one called tag_page_data.

When a Tag in a post is clicked on, I want the Tag page to grab custom field 1 from the tag_page_layout, and then a couple custom fields worth of data from tag_page_data.

I probably wouldn't even need the two post types if I took the time to learn the PHP or HTML code for making tabs, but again, I'm using a plug-in for Wordpress shortcode (which, if you see above - I'm not even sure is going to work right - of course if its not I'm willing to make multiple of these 'layout' posts so each [tab:NAME] shortcode bit is in it's own post-content area.

So... the tag page will basically have a big bit of code that runs before the loop.... it knows its on a tag page so it starts loading Custom Field 1 from the tag_page_layout, which is essentially a bit of code that starts up a Tab-separated data presentation area. Then it's got to take the tag clicked and match it with the same tag ID from custom post type #2 - the tag_page_data group. Then it will grab the first 3 or so fields from that page, swap back to the layout post, throw another custom field from there to start another tab, and so on and so forth, until a [tab:END] and it runs the loop.

I could include all my various attempts and bits of code that never worked or half worked, but I've been around so many circles trying to construct this. Like I said, my coding knowledge is limited but I can usually feel my way around, however these finer points of trying to make Wordpress a little more CMS-like seem to be harder for me to grasp. Any help would be appreciated!

+1  A: 

As far as using shortcodes in custom fields go, this should help you out, where XXX is your custom field name.

<?php
$var = apply_filters('the_content', get_post_meta($post->ID, 'XXX', $single = true) );
echo $var;
?>

This apply's the standard filters wordpress automatically runs on regular post content, allowing it to process your custom field and convert the shortcode.

Jervis