Jemand schrieb diesen PHP-Code und verließ schließlich die Firma. Ich bin ein neuer Mitarbeiter und ich versuche, eine Schleife mit diesem Code zu brechen, schrieb er. Momentan werden 9 Videoartikel auf einer einzigen Seite in einer Schleife wiedergegeben. Ich versuche, die Schleife zu durchbrechen und auf 5 Videoartikel zu beschränken und ein "Mehr Videos sehen!" Hinzuzufügen. verlinke und zeige den Rest des Videos auf der zweiten Seite, ohne den Code, den er geschrieben hat, zu brechen.Wie kann ich eine While-Schleife unterbrechen?
Code:
<?php
$count = 0;
$limit = 5;
if (have_posts()) : while ($count < $limit && have_posts()) : the_post();
$this_timestamp = date('l F j, Y', strtotime($post->post_date));
$this_categories = wp_get_post_categories($post->ID);
$this_excerpt = $post->post_content;
$this_featuredVideo = get_post_meta($post->ID, 'post_featuredVideo', true);
$this_featuredVideoTitle = get_post_meta($post->ID,'post_featuredVideoTitle',true);
$this_gallery = get_post_meta($post->ID, 'post_imageGallery', true);
++count;
?>
<article class="unum_article">
<header class="unum_article-header clearfix">
<time class="unum_article-header_timestamp"><?php echo $this_timestamp; ?></time>
</header>
<figure class="unum_article-media">
<?php if ($this_featuredVideo && !($this_gallery)): ?>
<div class="flowplayer fp-outlined is-splash fp-mute" style="background-image:url(<?php echo get_the_post_thumbnail_url($post->ID,'full');?>)" data-analytics="UA-2775729-22" data-key="$845219950943213,$437146226347740" data-share="false" title="<?php echo $this_featuredVideoTitle; ?>">
<video >
<source src="<?php echo $this_featuredVideo; ?>" type="video/mp4">Your browser does not support the video tag.</source>
</video>
</div>
<?php else: ?>
<a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($post->ID,'full',array('class' => "unum_article-media_content")); ?></a>
<?php endif; ?>
</figure>
<h2 class="unum_article-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="unum_article-content">
<p><?php echo the_content('Read More', true); ?></p>
</div>
<ul class="unum_article-tags">
<?php
foreach($this_categories as $cat):
$category = get_category($cat);
?>
<li><a href="<?php echo esc_url(get_category_link($cat)); ?>"><?php echo $category->name; ?></a></li>
<?php endforeach; ?>
</ul>
</article>
<?php endwhile; ?>
SO keine Codierung Dienst ist, Wir fragen hier nicht nach Code –
Fügen Sie eine Zählervariable hinzu. – aynber
umm mit 'break' – ArtisticPhoenix