0
votes

Hi I'm wondering if anyone would know the best way to go about equipping the back end of wordpress to allow me to readily customize post layout's in several different variations, but not via custom post /category/tag templates or custom post types. What I've been trying to do is add custom fields at a time, each with a different layout, each for consecutive sections of the main article post so I can pick and choose how each part of the article should look.

My guess it aht I'd need some sort of code to keep letting me add custom fields to the body of the post, as some of sections of the article may have repeated layouts (e.g. img on left text on right, or img above text below). So far I've been trying to use Advanced Custom Fields plug in for the custom fields - but I'm stuck on two parts.

The first is how to make a custom field specifically for layout only, as in div containers with css attributes for other things such as, text, images, galleries, embedded videos etc to go inside.

The second is as stated earlier, my presumption that I will need to somehow allow the repeated addition of custom fields to a certain section of the post body, and how I'd do this as right now I can't think of a way.

1

1 Answers

0
votes

Depending on how many you have I would go with custom post types. But if you only have a few You could create triggers for conditional CSS.

Save a custom field on your post like this:

background => green

Then on post template:

// echo the string "green"
<div class="" style="<?php echo get_post_meta( $post_id, background, true ); ?>"  ></div>

Or you could create a custom class to style your stylsheet for your super special post:

.awesomepost{ bunchastuff:amazing; }

Then in your post custom field create

stylefiftythree => awesomepost

and in the div you want to add the class to echo the awesome post within the class attribute.

<div class="<?php echo get_post_meta( $post_id, stylefiftythree, true ); ?>" style=""  ></div>

After coding this I realize this is terrible. Keeping track of these pages and their styles alone is terrific. You have to go with CPT's or Page templates unless you have like under 10 of these scenarios.