admin管理员组文章数量:1326277
i have a loop that fetch custom post type from the database now when i go to the page the data doesnt appear but when i refresh the page 2 times the data shows here is the code:
<div class="expertise-menu">
<?php
echo get_the_id();
$args = array(
'posts_per_page' => -1,
'post_type' => 'syllabus',
array(
'key' => 'related_expertise',
'compare' => 'LIKE',
'value' => get_the_id()
)
);
$syllabus = new WP_Query($args);
if($syllabus->have_posts()) {
while( $syllabus->have_posts()) {
$syllabus->the_post();
?>
<div class="expertise-menu__box" data-expertise="<?= get_field("related_expertise")[0]->post_name; ?>">
<input type="checkbox" class="expertise-menu__input"
name="<?= get_field("related_expertise")[0]->post_name; ?>" id="<?= get_the_id(); ?>">
<label for="<?= get_the_id(); ?>" class="expertise-menu__label">
<span class="svg-box">
<svg viewBox="0 0 100 100">
<path class="svg-rect"
d="M82,89H18c-3.87,0-7-3.13-7-7V18c0-3.87,3.13-7,7-7h64c3.87,0,7,3.13,7,7v64C89,85.87,85.87,89,82,89z" />
<polyline class="svg-check" points="25.5,53.5 39.5,67.5 72.5,34.5 " />
</svg>
</span>
<a href="<?= get_the_permalink(); ?>" class="expertise-menu__link">
<span class="expertise-menu__text"><?= get_the_title(); ?></span>
<span
class="expertise-menu__text expertise-menu__text--sub"><?= get_field('syllabus_code'); ?></span>
</a>
<span class="expertise-menu__arrow">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-chevron-right"
fill="currentColor" xmlns=";>
<path fill-rule="evenodd"
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" />
</svg>
</span>
</label>
</div>
<?php } wp_reset_query(); ?>
<?php } ?>
</div>
<!-- Expertise Menu END -->
i have a loop that fetch custom post type from the database now when i go to the page the data doesnt appear but when i refresh the page 2 times the data shows here is the code:
<div class="expertise-menu">
<?php
echo get_the_id();
$args = array(
'posts_per_page' => -1,
'post_type' => 'syllabus',
array(
'key' => 'related_expertise',
'compare' => 'LIKE',
'value' => get_the_id()
)
);
$syllabus = new WP_Query($args);
if($syllabus->have_posts()) {
while( $syllabus->have_posts()) {
$syllabus->the_post();
?>
<div class="expertise-menu__box" data-expertise="<?= get_field("related_expertise")[0]->post_name; ?>">
<input type="checkbox" class="expertise-menu__input"
name="<?= get_field("related_expertise")[0]->post_name; ?>" id="<?= get_the_id(); ?>">
<label for="<?= get_the_id(); ?>" class="expertise-menu__label">
<span class="svg-box">
<svg viewBox="0 0 100 100">
<path class="svg-rect"
d="M82,89H18c-3.87,0-7-3.13-7-7V18c0-3.87,3.13-7,7-7h64c3.87,0,7,3.13,7,7v64C89,85.87,85.87,89,82,89z" />
<polyline class="svg-check" points="25.5,53.5 39.5,67.5 72.5,34.5 " />
</svg>
</span>
<a href="<?= get_the_permalink(); ?>" class="expertise-menu__link">
<span class="expertise-menu__text"><?= get_the_title(); ?></span>
<span
class="expertise-menu__text expertise-menu__text--sub"><?= get_field('syllabus_code'); ?></span>
</a>
<span class="expertise-menu__arrow">
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-chevron-right"
fill="currentColor" xmlns="http://www.w3/2000/svg">
<path fill-rule="evenodd"
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z" />
</svg>
</span>
</label>
</div>
<?php } wp_reset_query(); ?>
<?php } ?>
</div>
<!-- Expertise Menu END -->
Share
Improve this question
asked Aug 4, 2020 at 5:56
Or ShalmayevOr Shalmayev
1032 bronze badges
1 Answer
Reset to default 0found the solution the problem was the "posts_per_page" it made my website crash on that specific section and also in wp-config.php added
define( 'WP_MEMORY_LIMIT', '256M' );
and it solved my problem
本文标签: phpwhen looping through custom post data not appearing
版权声明:本文标题:php - when looping through custom post data not appearing 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742211482a2433793.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论