WordPress.org

Ready to get started?Download WordPress

Forums

How can i fix this error (34 posts)

  1. TataVostru
    Member
    Posted 2 years ago #

    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

  2. hattendesign
    Member
    Posted 2 years ago #

    <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>
  3. hattendesign
    Member
    Posted 2 years ago #

    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

  4. TataVostru
    Member
    Posted 2 years ago #

    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. -->
  5. hattendesign
    Member
    Posted 2 years ago #

    [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]

  6. TataVostru
    Member
    Posted 2 years ago #

    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; }?>
  7. TataVostru
    Member
    Posted 2 years ago #

    :D 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>
  8. TataVostru
    Member
    Posted 2 years ago #

    i want to get automatic trailers by title....

  9. hattendesign
    Member
    Posted 2 years ago #

    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.

  10. TataVostru
    Member
    Posted 2 years ago #

    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

  11. TataVostru
    Member
    Posted 2 years ago #

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

  12. hattendesign
    Member
    Posted 2 years ago #

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

  13. TataVostru
    Member
    Posted 2 years ago #

    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

  14. TataVostru
    Member
    Posted 2 years ago #

    yes i put one video per post..

  15. TataVostru
    Member
    Posted 2 years ago #

    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

  16. hattendesign
    Member
    Posted 2 years ago #

    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]

  17. TataVostru
    Member
    Posted 2 years ago #

    ok , 2 seconds...

  18. TataVostru
    Member
    Posted 2 years ago #

    it apears only Related Trailers

  19. TataVostru
    Member
    Posted 2 years ago #

    i put the tag Batleship, on evrey trailer

  20. hattendesign
    Member
    Posted 2 years ago #

    send me the link to your page

  21. TataVostru
    Member
    Posted 2 years ago #

    http://

  22. TataVostru
    Member
    Posted 2 years ago #

    do you have a Yahoo ID?

  23. hattendesign
    Member
    Posted 2 years ago #

    I THINK YOU HAVE MORE THAN ONE TAG PER POST. TRY THIS...

    [ 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]

  24. TataVostru
    Member
    Posted 2 years ago #

    below is trailere.php

    [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]

  25. hattendesign
    Member
    Posted 2 years ago #

    so where are the Etichete tags coming from?

  26. TataVostru
    Member
    Posted 2 years ago #

    Ethichete Tags : is the tags from POST

    Trailers Tags : http://www.diviziatm.ro/6.jpg

  27. hattendesign
    Member
    Posted 2 years ago #

    OK try this instead...

    http://pastebin.com/jGhiBMa1

    They cleared your code so just replace the code I sent before with this one.

  28. hattendesign
    Member
    Posted 2 years ago #

    PS It won't generate a thumbnail I just want to see if it gets results

  29. TataVostru
    Member
    Posted 2 years ago #

    nothing

  30. TataVostru
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic