WordPress.org

Ready to get started?Download WordPress

Forums

WordPress- Displaying and layering custom fields/posts (1 post)

  1. duiwel
    Member
    Posted 3 years ago #

    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's 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!

Topic Closed

This topic has been closed to new replies.

About this Topic