簡體   English   中英

新增中 <details></details> 到一個特定的Buddypress Xprofile字段(profile-loop.php)

[英]Adding <details></details> to one specific Buddypress Xprofile field (profile-loop.php)

如果id = 10的特殊xprofile字段具有數據,則輸出以下內容:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><details><?php bp_the_profile_field_value(); ?></details></td>

</tr>

對於具有數據的所有其他xprofile字段,輸出應為:

<tr<?php bp_field_css_class(); ?>>

    <td class="label"><?php bp_the_profile_field_name(); ?></td>

    <td class="data"><?php bp_the_profile_field_value(); ?></td>

</tr>

如何更改buddypress profile-loop.php中的第二個while循環?

<div class="bp-widget <?php bp_the_profile_group_slug(); ?>">

  <h2><?php bp_the_profile_group_name(); ?></h2>

  <table class="profile-fields">

    <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>

      <?php if ( bp_field_has_data() ) : ?>

        <tr<?php bp_field_css_class(); ?>>

          <td class="label"><?php bp_the_profile_field_name(); ?></td>

          <td class="data"><?php bp_the_profile_field_value(); ?></td>

        </tr>

      <?php endif; ?>

      <?php

      do_action( 'bp_profile_field_item' ); ?>

    <?php endwhile; ?>

  </table>
</div>

我只是使用bp_get_the_profile_field_id()解決了它:

<div class="bp-widget <?php bp_the_profile_group_slug(); ?>">
  <h2><?php bp_the_profile_group_name(); ?></h2>
    <table class="profile-fields">
      <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
      <?php if ( bp_get_the_profile_field_id() != '273' AND bp_field_has_data()) : ?>
      <tr<?php bp_field_css_class(); ?>>
        <td class="label"><?php bp_the_profile_field_name(); ?></td>
        <td class="data"><?php bp_the_profile_field_value(); ?></td>
      </tr>
      <?php else : ?>
      <tr<?php bp_field_css_class(); ?>>
        <td class="label"><?php bp_the_profile_field_name(); ?></td>
        <td class="data"><details><summary>Anzeigen</summary><?php bp_the_profile_field_value(); ?></details></td>
      </tr>
      <?php endif;?>
...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM