我有一个WordPress网站,我想显示当前类别中所有帖子的列表(当前帖子除外)。
我需要使用名为" test"的特定Realm realmThread = Realm.getDefaultInstance();
PropertyObject currProperty = realmThread.where(PropertyObject.class).equalTo("propertyId", propertyId).findFirst();
if (currProperty != null) {
int propertyFollow = Integer.parseInt(params[1]);
realmThread.beginTransaction();
currProperty.setPropertyFollowed(propertyFollow);
realmThread.commitTransaction();
if (propertyFollow == 1) {
String propertyString = visnetawrap.gsonClient.toJson(currProperty);
realmThread.beginTransaction();
FavoriteObject newFavProperty = realmThread.createOrUpdateObjectFromJson(FavoriteObject.class, propertyString);
realmThread.commitTransaction();
Log.d("NewFavorite", newFavProperty.toString());
}
的值作为锚文本。而不是帖子标题。
如何编辑以下代码并排除当前帖子?
custom-field
答案 0 :(得分:1)
这可能有效:
<?php
global $post;
$categories = get_the_category();
$currentID = get_the_ID();
foreach ($categories as $category) :?>
<ul>
<?php
$posts = get_posts('numberposts=3&category='. $category->term_id);
foreach($posts as $post) :
if ( $currentID != $post->ID ) {
?>
$test_value = get_post_meta( $post->ID, 'test', true );
?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if ( ! empty( $test_value ) ) {echo $test_value; } else { echo 'Nothing'; } ?>
</a>
</li><?php
} ?>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>