• hello everyone

    i need some help with my little php problem.
    i have two custom-fields in my wp called “vorschautext” and “artikelbild”. artikelbild is an image, and vorschautext is a little text.

    my probem is now, that i want an if/else.

    if this custom fields are empty should come the wp-normal content, like that:


    if(vorschautext = empty and vorschaubild = empty){
    the_content(”);
    }else{
    echo vorschautext and vorschaubild
    }

    i tried to solve that with that code, but that doesnt works:


    <?php
    $vorschautext = get_post_custom_values(‘vorschautext’);
    $artikelbild = get_post_meta($post->ID, (‘artikelbild’), true);

    if((empty($vorschautext) && empty($artikelbild)){
    the_content(‘Lese den Rest dieser Story »’);

    }else{
    echo ‘<img src=”‘ . $artikelbild . ‘” />’ . $vorschautext;
    }
    ?>

    does anyone need a soltion??
    thank you very much!
    rho

Viewing 1 replies (of 1 total)
  • Did you already have a solution for this?

    Because i’m searching for something similar. I have 2 custom fields URL/THUMB (for the use of videos) and i want to create an if else, if get_post_custom_values are empty, i want to switch to the_content (for the news).

    I also tried to filter by category but that gives me troubles with category-xx.php files. And too much customization.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Fields with if/else’ is closed to new replies.