Viewing 5 replies - 1 through 5 (of 5 total)
  • https://newbedev.com/get-term-archive-url-link ?

    • This reply was modified 2 years, 6 months ago by diagonale.
    Thread Starter IdeFixx

    (@idefixx)

    Thanks @diagonale, that’s not exactly what I’m looking for.

    Lower is the code from twentytwenty child theme functions.php.

    It’s almost done, except one thing -> Checking of the post meta variables/values does not work. For example if some post does not have a tag, empty HTML is shown.

    add_action( 'after_setup_theme', function() {
    	add_filter( 'twentytwenty_post_meta_location_single_top', function() {
    		?>
    			<div class="post-meta-wrapper<?php echo esc_attr( $post_meta_wrapper_classes ); ?>">
    				<ul class="post-meta<?php echo esc_attr( $post_meta_classes ); ?>">
    				<?php
    					if ( ! empty ( 'post-date' ) ) {
    				?>
    					<li class="post-date meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php _e( 'Post date', 'twentytwenty' ); ?></span>
    							<?php twentytwenty_the_theme_svg( 'calendar' ); ?>
    						</span>
    						<span class="meta-text">
    							<a href="<?php echo get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'));  ?>"><?php the_time( get_option( 'date_format' ) ); ?></a>
    						</span>
    					</li>
    				<?php
    					}
    					else { echo 'nothing1'; }
    				?>
    				<?php
    					if ( ! empty ( 'tags' ) ) {
    				?>
    					<li class="post-tags meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php _e( 'Tags', 'twentytwenty' ); ?></span>
    							<?php twentytwenty_the_theme_svg( 'tag' ); ?>
    						</span>
    						<span class="meta-text">
    							<?php the_tags( '', ', ', '' ); ?>
    						</span>
    					</li>
    				<?php
    					}
    					else { echo 'nothing2'; }
    				?>
    				<?php
    					if ( ! empty ( 'comments' ) ) {
    				?>
    					<li class="post-comment-link meta-wrapper">
    						<span class="meta-icon">
    							<?php twentytwenty_the_theme_svg( 'comment' ); ?>
    						</span>
    						<span class="meta-text">
    							<?php comments_popup_link(); ?>
    						</span>
    					</li>
    				<?php
    					}
    					else { echo 'nothing3'; }
    				?>
    				</ul>
    			</div>
    		<?php
    		}
    	);
    	} 
    );

    Here are some similar questions:

    Useful links:

    Hey
    Instead of get_template_directory_uri() use get_stylesheet_directory_uri() to get the child theme’s directory.
    Phil

    Thread Starter IdeFixx

    (@idefixx)

    Hi @philhuhn, thanks, but this (URI link change) does not solve my problem. Even with this code require get_stylesheet_directory_uri() . '/inc/template-tags.php' it’s impossible to load that piece of lovely code. Finally, after some RTFM readings I know why (links in my previous post).

    Anyway -> Problem solved, here’s an updated child theme functions.php:

    add_action( 'after_setup_theme', function() {
    	add_filter( 'twentytwenty_post_meta_location_single_top', function() {
    		?>
    			<div class="post-meta-wrapper<?php echo esc_attr( $post_meta_wrapper_classes ); ?>">
    				<ul class="post-meta<?php echo esc_attr( $post_meta_classes ); ?>">
    					<li class="post-date meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php _e( 'Post date', 'twentytwenty' ); ?></span>
    							<?php twentytwenty_the_theme_svg( 'calendar' ); ?>
    						</span>
    						<span class="meta-text">
    							<a href="<?php echo get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'));  ?>"><?php the_time( get_option( 'date_format' ) ); ?></a>
    						</span>
    					</li>
    				<?php
    					$post_tags = get_the_tags();
    					if ( ! empty ( $post_tags ) ) {
    				?>
    					<li class="post-tags meta-wrapper">
    						<span class="meta-icon">
    							<span class="screen-reader-text"><?php _e( 'Tags', 'twentytwenty' ); ?></span>
    							<?php twentytwenty_the_theme_svg( 'tag' ); ?>
    						</span>
    						<span class="meta-text">
    							<?php the_tags( '', ', ', '' ); ?>
    						</span>
    					</li>
    				<?php
    					}
    					//else { echo 'no tags'; }
    				?>
    				<?php
    					if ( ! empty ( $comments ) ) {
    				?>
    					<li class="post-comment-link meta-wrapper">
    						<span class="meta-icon">
    							<?php twentytwenty_the_theme_svg( 'comment' ); ?>
    						</span>
    						<span class="meta-text">
    							<?php comments_popup_link(); ?>
    						</span>
    					</li>
    				<?php
    					}
    					//else { echo 'no comments'; }
    				?>
    				<?php
    					if ( is_sticky() ) {
    				?>
    					<li class="post-sticky meta-wrapper">
    						<span class="meta-icon">
    							<?php twentytwenty_the_theme_svg( 'bookmark' ); ?>
    						</span>
    						<span class="meta-text">
    							<?php _e( 'Sticky post', 'twentytwenty' ); ?>
    						</span>
    					</li>
    				<?php
    					}
    					//else { echo 'not a sticky post'; }
    				?>
    				</ul>
    			</div>
    		<?php
    		}
    	);
    	} 
    );

    And remove tags in the bottom:

    add_filter(
    	'twentytwenty_post_meta_location_single_bottom',
    	array(
    		//'tags',
    	)
    );
    Thread Starter IdeFixx

    (@idefixx)

    Complete child theme’s code is here: https://github.com/idefixxed/automat-2020

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Date archive link in child theme’ is closed to new replies.