Last active
September 9, 2020 14:34
-
-
Save jmarreros/3746ccf42efe8dbdb7f70b4b9fbd6c8b to your computer and use it in GitHub Desktop.
Inserta el subtítulo en el detalle de páginas o entradas basado en un campo personalizado llamado Subtitulo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Esta línea no se debe copiar | |
add_action( 'wp_print_footer_scripts', function () { | |
if (is_singular()): | |
$subtitulo = get_post_meta(get_the_ID(), 'Subtitulo', true); | |
if ( $subtitulo ): | |
?> | |
<script> | |
(function( $ ) { | |
let str = '<span class="dcms-subtitle">'; | |
str += '<?= $subtitulo ?>'; | |
str += '</span>'; | |
$(str).insertAfter('.entry-title'); | |
})( jQuery ); | |
</script> | |
<?php | |
endif; | |
endif; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment