Skip to content

Instantly share code, notes, and snippets.

@webbingstudio
Last active January 4, 2023 07:47
Show Gist options
  • Save webbingstudio/8a524f55cba794e79fb4d5babf625477 to your computer and use it in GitHub Desktop.
Save webbingstudio/8a524f55cba794e79fb4d5babf625477 to your computer and use it in GitHub Desktop.
WordPressテーマ「Snow Monkey」のフックを利用して、カスタム投稿タイプ「test」のメタ情報を、Advanced Custom Fieldsで作成したカスタムフィールド「sample」の値に差し替える
function mysm_render_meta( $html, $name, $vars ) {
if( ( get_post_type() === 'test' ) || ( is_post_type_archive( 'test' ) ) ) {
$html = <<< EOL
<div class="c-entry-summary__meta">
<ul class="c-meta">
<li class="c-meta__item c-meta__item--sample">
EOL;
$html .= get_field('sample');
$html .= <<< EOL
</li>
</ul>
</div>
EOL;
}
return $html;
}
add_filter(
'snow_monkey_template_part_render_template-parts/loop/entry-summary/meta/meta',
'mysm_render_meta',
10,
3
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment