Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- < ?php // ENVIAR AL DATALAYER SI ES CATEGORIA, PAGINA O HOME ?>
- < ?php if (is_singular('post')) : ?>
- <script>
- dataLayer=[{
- 'Fecha': '< ?php echo get_the_date(); ?>',
- 'Autor': '< ?php the_author_meta( 'ID' ); ?>',
- 'Titulo': '< ?php the_title(); ?>',
- 'Formato': '< ?php print get_post_format() ? : 'standard'; ?>',
- < ?php
- $categories = get_the_category();
- $separator = ', ';
- $output = '';
- if ( ! empty( $categories ) ) {
- foreach( $categories as $category ) {
- $output .= esc_html( $category->name );
- break;
- }
- echo "'Categorias':'" . trim($output, $separator) . "'";
- }
- ?>
- }];
- </script>
- < ?php endif; ?>
- < ?php if (is_category()) : ?>
- <script>
- dataLayer=[{
- < ?php
- $categories = get_the_category();
- $separator = ', ';
- $output = '';
- if ( ! empty( $categories ) ) {
- foreach( $categories as $category ) {
- $output .= esc_html( $category->name );
- break;
- }
- echo "'Categorias':'" . trim($output, $separator) . "'";
- }
- ?>
- }];
- </script>
- < ?php endif; ?>
- < ?php // FIN ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement