Support » Theme: Twenty Twenty » display the labels in the pages

  • Resolved gwenm

    (@gwenm)


    Hello, how do I display the tags in the pages?
    I have a child theme and I have installed a plugin to add tags to the pages.
    I know there is a the_tags() function but I’m not sure.
    Thank you for help 🙂

    • This topic was modified 1 year, 8 months ago by gwenm.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter gwenm

    (@gwenm)

    I followed this tutorial https://www.namehero.com/startup/how-to-include-pages-in-wordpress-tag-queries/ to add the tag function to my pages and removed the plugin.
    I can’t display the tags correctly in (templates/template-full-width.php)
    If I add the_tags(); , the tags are displayed either at the top or bottom of the page. I would like them to be displayed normally as in the articles. Why is it not displayed?

    templates/template-full-width.php

    <?php
    /**
     * Template Name: Full Width Template
     * Template Post Type: post, page
     *
     * @package WordPress
     * @subpackage Twenty_Twenty
     * @since Twenty Twenty 1.0
     */
    
    get_template_part( 'singular' ); the_tags();
    

    My function.php

    <?php
    /* enqueue scripts and style from parent theme */        
    function twentytwenty_styles() {
    	wp_enqueue_style( 'parent', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'twentytwenty_styles');
    // add tag support to pages
    function tags_support_all() {
    	register_taxonomy_for_object_type('post_tag', 'page');
    }
    add_action('init', 'tags_support_all');
    // ensure all pages are included in tag queries
    function tags_support_query($wp_query) {
    	if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
    }
    add_action('pre_get_posts', 'tags_support_query');
    // mise a jour
    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time('U'); 
    $u_modified_time = get_the_modified_time('U'); 
    if ($u_modified_time >= $u_time + 86400) { 
    $updated_date = get_the_modified_time('j F, Y');
    $updated_time = get_the_modified_time('h:i a'); 
    $custom_content .= '<p class="last-updated">Dernière modification le '. $updated_date .'</p>';  
    } 
     
        $custom_content .= $content;
        return $custom_content;
    }
    add_filter( 'the_content', 'wpb_last_updated_date' );
    Thread Starter gwenm

    (@gwenm)

    I wonder if it wouldn’t come from this function located in the (inc/template-tags.php)

    /**
     * Post Meta
     */
    
    /**
     * Retrieves and displays the post meta.
     *
     * If it's a single post, outputs the post meta values specified in the Customizer settings.
     *
     * @param int    $post_id  The ID of the post for which the post meta should be output.
     * @param string $location Which post meta location to output – single or preview.
     */
    function twentytwenty_the_post_meta( $post_id = null, $location = 'single-top' ) {
    
    	echo twentytwenty_get_post_meta( $post_id, $location ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_post_meta().
    
    }
    
    Thread Starter gwenm

    (@gwenm)

    It’s been 4 days now that I’ve been trying to display my tags in my pages. Where to get help ? thanks

    • This reply was modified 1 year, 8 months ago by gwenm.

    Although you have been working on this problem for four days, your question only appeared here one day and 19 hours ago. Please remember that any answer comes from a volunteer who may not have the time to answer immediately.

    One thing that might help anyone able to answer your question is to give the page on which the problem appears. Sadly, I am not able to help.

    Thread Starter gwenm

    (@gwenm)

    Yes of course, I understand what you are saying. I also thank the volunteers.
    I’ve turned the pages into articles, so that the tags are displayed.
    Thanks for your feedback 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘display the labels in the pages’ is closed to new replies.