• In my header.php file, I have a “bannerimg” div that displays the featured image and title of a certain post/page…
    I have created 2 custom meta boxes for the client so they can customize the styling of the_title, depending on which image they use as the featured… so if they wanted it to be blue text in the top right of the image, they can easily do that… Here is the list of my custom post meta below.

    Title Text Position: Top Left, Top Right, Bottom Left, Bottom Right
    Title Text Color: Black, White, Blue

    Now I know how to grab the users selection: get_post_meta(‘position’)

    I need someone to tell me how I can give my title text div, the meta class the user selected.

Viewing 1 replies (of 1 total)
  • Thread Starter andybrazil

    (@andybrazil)

    okay obviously no one cared enough to respond to my request for an answer… but i figured it out myself. heres the answer
    Put this code with your banner image which has custom meta boxes in the backend.

    <?php global $page, $post;
    $color = get_post_meta($post->ID, ‘text_color’, TRUE);
    $position = get_post_meta($post->ID, ‘text_position’, TRUE);
    switch( $position ){
    case “Top Left”:
    $position = “topleft”;
    break;
    }

    that gets the post meta and defines a variable of “color” and “position”
    you can then input this code where your banner image div is:

    <h2 class=”bannertitle <?=$position;?> <?=$color;?>”>

    and finally in your style sheet, define the classes “topleft”

Viewing 1 replies (of 1 total)
  • The topic ‘Get Post Meta and Give a Div a User Selected Class’ is closed to new replies.