Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress get_发布自定义类别_Wordpress_Loops_Post_Get - Fatal编程技术网

Wordpress get_发布自定义类别

Wordpress get_发布自定义类别,wordpress,loops,post,get,Wordpress,Loops,Post,Get,你们能帮我一下吗,我正在试着只过滤我的post循环中的夜生活事件代码 var locations = [<?php $posts = get_posts(array( 'posts_per_page' => -1, 'post_type' => 'post', 'category' => 'nightlife' )); if( $posts ): ?> <?php forea

你们能帮我一下吗,我正在试着只过滤我的post循环中的夜生活事件代码

var locations = [<?php 

$posts = get_posts(array(
    'posts_per_page'    => -1,
    'post_type'         => 'post',
    'category' => 'nightlife'
));

if( $posts ): ?>

                <?php foreach( $posts as $post ):
setup_postdata( $post );
?> {
                    lat: <?php the_field('lattitude'); ?>,
                    lng: <?php the_field('longitude'); ?>,
                    info: '<div class="onMapSingleWrapper"><h1 class="onMapTitle"><?php the_title(); ?></h1><p class="onMapDate"><?php the_field('date_de_levenement'); ?></p><p class="onMapPrice"><?php the_field('prix_de_levenement'); ?>$</p><p class="onMapFilter"><?php the_field('filtres'); ?></p></div>'
                },

                <?php endforeach; ?>

                <?php wp_reset_postdata(); ?>

                <?php endif; ?>
            ];

            google.maps.event.addDomListener(window, "load", initMap);
var位置=[
{
拉丁语:,
液化天然气:,
信息:'

$

' }, ]; google.maps.event.addDomListener(窗口“加载”,initMap);
我总是得到我所有的帖子,我只想要夜生活类的帖子


谢谢

我终于拿到了,如果有人需要,就在这里

$catSelect = '';

$posts = get_posts(array(
    'posts_per_page'    => -1,
    'post_type'         => 'post',
    'category_name' => $catSelect
));

if( $posts ): ?>

                <?php foreach( $posts as $post ):
setup_postdata( $post );
?> {
                    lat: <?php the_field('lattitude'); ?>,
                    lng: <?php the_field('longitude'); ?>,
                    info: '<div class="onMapSingleWrapper"><h1 class="onMapTitle"><?php the_title(); ?></h1><p class="onMapDate"><?php the_field('date_de_levenement'); ?></p><p class="onMapPrice"><?php the_field('prix_de_levenement'); ?>$</p><p class="onMapFilter"><?php the_field('filtres'); ?></p></div>'
                },

                <?php endforeach; ?>

                <?php wp_reset_postdata(); ?>

                <?php endif; ?>
            ];

            google.maps.event.addDomListener(window, "load", initMap);
$catSelect='';
$posts=获取_posts(数组(
“每页帖子数”=>-1,
“post_type”=>“post”,
“类别名称”=>$catSelect
));
如果($员额):?>
{
拉丁语:,
液化天然气:,
信息:'

$

' }, ]; google.maps.event.addDomListener(窗口“加载”,initMap);