WordPress.org

Support

Support » How-To and Troubleshooting » How can i fix this error

How can i fix this error

  • TataVostru
    Member

    @tatavostru

    Hy,
    i’m building a cinema website, i get an error if there is no content,

    http://www.diviziatm.ro/1.jpg

    In the website i get this if i have no content:

    Warning: Invalid argument supplied for foreach() in /home/cinema/public_html/cinema/wp-content/themes/movies/tabfilm/detali-film.php on line 25

    My code for display scenarist is under:

    <span class="film"><b>Scenarist</b><br />
    <?php foreach(get_field('scenaristi') as $post_object): ?>
    <a class="arh-link" href="<?php echo get_permalink($post_object->ID); ?>">
    <?php echo get_the_title($post_object->ID) ?></a><br /> <?php endforeach; ?>
    </span>

    For example: if i do not want to display something, i wish to apear the text: No actors.

    Thanks. Excuse my english

Viewing 15 replies - 1 through 15 (of 33 total)
  • hattendesign
    Member

    @hattendesign

    <span class="film"><b>Scenarist</b><br />
    <?php
    if(get_field('scenaristi') != "") {
     foreach(get_field('scenaristi') as $post_object): ?>
    <a class="arh-link" href="<?php echo get_permalink($post_object->ID); ?>">
    <?php echo get_the_title($post_object->ID) ?></a><br /> <?php endforeach;
    }
     ?>
    </span>
    hattendesign
    Member

    @hattendesign

    OR…..

    <span class="film"><b>Scenarist</b><br />
    <?php
    if(count(get_field('scenaristi')) > 0):
     foreach(get_field('scenaristi') as $post_object): ?>
    <a class="arh-link" href="<?php echo get_permalink($post_object->ID); ?>">
    <?php echo get_the_title($post_object->ID) ?></a><br /> <?php endforeach;
    endif;
     ?>
    </span>

    SHOULD DO IT TOO

    TataVostru
    Member

    @tatavostru

    thanks, can you tell me for distribution, i use :

    <div class="actori-film-box">
    <?php foreach(get_field('distributie') as $post_object): ?>
    <div class="act-box">
    <img class="actor_img" src="/scripts/timthumb.php?src=<?php echo get_field( 'img_actor', $post_object->ID ); ?>&h=70&w=50&zc=1" alt="" />
    <span class="act-titlu">
    <a href="<?php echo get_permalink($post_object->ID); ?>">
    <?php echo get_the_title($post_object->ID) ?></a>
    </span>
    </div>
    <?php endforeach; ?>
    </div>
    </div>
    <!-- End. -->
    hattendesign
    Member

    @hattendesign

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    TataVostru
    Member

    @tatavostru

    fix :

    <?php
    if(get_field('distributie') != "") {
     foreach(get_field('distributie') as $post_object): ?>
    <div class="act-box">
    <img class="actor_img" src="/scripts/timthumb.php?src=<?php echo get_field( 'img_actor', $post_object->ID ); ?>&h=70&w=50&zc=1" alt="" />
    <span class="act-titlu">
    <a href="<?php echo get_permalink($post_object->ID); ?>">
    <?php echo get_the_title($post_object->ID) ?></a>
    </span>
    </div>
    <?php endforeach; }?>
    TataVostru
    Member

    @tatavostru

    😀 thanks man, if you ar kind and if you know, how can i display the related trailers… if i have for example 5 trailers Prometeus, clips, promo..etc..

    Ex: http://www.diviziatm.ro/2.jpg

    I use:

    <div class="box-trailere">
    <div class="trailer-img">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Trailer film %s', 'kubrick'), the_title_attribute('echo=0')); ?>">
    <span class="tip"><?php $key="tip"; echo get_post_meta($post->ID, $key, true); ?></span><span class="tip_trailer"><?php $key="tip_trailer"; echo get_post_meta($post->ID, $key, true); ?></span>
    <img src="http://img.youtube.com/vi/<?php $key="trailer"; echo get_post_meta($post->ID, $key, true); ?>/<?php $key="img_trailer"; echo get_post_meta($post->ID, $key, true); ?>"></a>
    <span class="duration"><?php $key="time"; echo get_post_meta($post->ID, $key, true); ?></span>
    </div>
    <span class="trailer-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Trailer film %s', 'kubrick'), the_title_attribute('echo=0')); ?>">
    <?php the_title(); ?>
    </a></span>
    </div>

    TataVostru
    Member

    @tatavostru

    i want to get automatic trailers by title….

    hattendesign
    Member

    @hattendesign

    How will the related trailer(s) be determined? I guess you can just create a related post by category or a function on the theme to loop it but that requires some coding.

    TataVostru
    Member

    @tatavostru

    Ex: i have 5 trailers added.. in varios categories
    EX:
    Cat:Trailer
    Subcat : Actions / Adventure / …

    Trailers
    -Prometeus HD
    -Prometeus Demo Trailer
    -Prometeus Oficial Movie
    -Prometeus Preview Movie

    In the Post Page in admin i have:
    http://www.diviziatm.ro/3.jpg

    How can i retrive the trailers without selecting them… i do not want to put evry time the trailers when i add them… Can i ?

    How i add trailer :
    http://www.diviziatm.ro/4.jpg

    TataVostru
    Member

    @tatavostru

    for example by tag… if i put the tag to all prometeus…

    hattendesign
    Member

    @hattendesign

    I’m confused…. Do you put all videos in 1 post? Or 1 video per post?

    TataVostru
    Member

    @tatavostru

    in POST i have the movie with all the things.. tabs…

    In the Persoane i have Actors, Regizors, Directors

    In Trailers – i have all trailers…
    How i add trailer :
    http://www.diviziatm.ro/4.jpg

    For example The page for trailers, the archive page…

    http://www.diviziatm.ro/5.jpg

    TataVostru
    Member

    @tatavostru

    yes i put one video per post..

    TataVostru
    Member

    @tatavostru

    I put one video per post in Trailer – Post Type

    In POST – i Add the movie Title… i add information about movie…

    I want to put all trailers that have the tag Ex: battleship … on the page…if you understand

    hattendesign
    Member

    @hattendesign

    TRY THIS (USING A TAG)…
    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

Viewing 15 replies - 1 through 15 (of 33 total)
  • The topic ‘How can i fix this error’ is closed to new replies.