Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jmarreros
Last active September 9, 2020 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmarreros/3746ccf42efe8dbdb7f70b4b9fbd6c8b to your computer and use it in GitHub Desktop.
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
<?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