使头像也成为超链接
Make Avatar also a hyperlink
我有 wordpress 模板的这部分行,显示团队成员的姓名并对其进行超链接。该超链接重定向到该成员的实际页面。
<h4 class="sc_team_item_title"><?php echo (!empty($post_options['link']) ? '<a href="'.esc_url($post_options['link']).'">' : '') . (!empty($post_data['post_id']) ? insurance_ancora_get_post_title($post_data['post_id']) : '') . (!empty($post_options['link']) ? '</a>' : ''); ?></h4>
在那行上方有一行显示该团队成员的照片:
<div class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>
我想使该图片也成为重定向到会员个人资料的超链接。
我对 PHP 很陌生,无论我尝试什么都失败了。你能帮我看看吗?
我想您需要的任何东西都在代码的第一部分。如果您需要整个 php 文件,请告诉我。
试试看:(希望它对你有用)
<div style="cursor: pointer;" onclick="window.location='<?php echo esc_url($post_options['link']); ?>';" class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>
或者检查var是否不为空可能更好
<div style="cursor: pointer;" onclick="window.location='<?php if(!empty($post_options['link'])){ echo esc_url($post_options['link']);} ?>';" class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>
我有 wordpress 模板的这部分行,显示团队成员的姓名并对其进行超链接。该超链接重定向到该成员的实际页面。
<h4 class="sc_team_item_title"><?php echo (!empty($post_options['link']) ? '<a href="'.esc_url($post_options['link']).'">' : '') . (!empty($post_data['post_id']) ? insurance_ancora_get_post_title($post_data['post_id']) : '') . (!empty($post_options['link']) ? '</a>' : ''); ?></h4>
在那行上方有一行显示该团队成员的照片:
<div class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>
我想使该图片也成为重定向到会员个人资料的超链接。 我对 PHP 很陌生,无论我尝试什么都失败了。你能帮我看看吗? 我想您需要的任何东西都在代码的第一部分。如果您需要整个 php 文件,请告诉我。
试试看:(希望它对你有用)
<div style="cursor: pointer;" onclick="window.location='<?php echo esc_url($post_options['link']); ?>';" class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>
或者检查var是否不为空可能更好
<div style="cursor: pointer;" onclick="window.location='<?php if(!empty($post_options['link'])){ echo esc_url($post_options['link']);} ?>';" class="sc_team_item_avatar"><?php insurance_ancora_show_layout($post_options['photo']); ?></div>