这是我想要做的......
我试图只在我的标题中显示第一个帖子,有点像特色帖子.我有它显示像我想,但它的循环通过所有的职位,所以不是只显示一个帖子它显示在我的头的所有文章.
这是我的代码:
<?php $i = 0; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $i++ ?>
<div class="post<?php if ($i == 1) echo ' first'; ?>">
*content to display post here*
</div>
<?php endwhile; ?>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud) 这是我有的:
HashMap<String,HashMap<Integer,Integer>> data =
new HashMap<String,HashMap<Integer,Integer>>();
Run Code Online (Sandbox Code Playgroud)
但我在添加值时遇到问题,因为内部hashmap没有名称(注意:它不应该).我实际上是在尝试将数组列表添加到HashMap中的第一个Integer中,所以我尝试的是:
data.put(var, data.get(array.get(x), y));
Run Code Online (Sandbox Code Playgroud)
它非常不喜欢,我对如何做到完全无能为力.