Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Create Page Templates For Tag Archive

Home Forums Support Create Page Templates For Tag Archive

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #504406
    Feri

    Hi,

    i try to create page template for my tags archives.

    <?php
    /* 
    Template Name: Tags Cloud
    */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    get_header(); ?>
    
    	<div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    			<?php
    			/**
    			 * generate_before_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_main_content' );
    
    			while ( have_posts() ) : the_post();
    
    				get_template_part( 'content', 'page' );
    
    				// If comments are open or we have at least one comment, load up the comment template.
    				if ( comments_open() || '0' != get_comments_number() ) : ?>
    
    					<div class="comments-area">
    						<?php comments_template(); ?>
    					</div>
    
    				<?php endif;
    
    			endwhile;
    
    			/**
    			 * generate_after_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_after_main_content' );
    			?>
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    	<?php
    	/**
    	 * generate_after_primary_content_area hook.
    	 *
    	 * @since 2.0
    	 */
    	 do_action( 'generate_after_primary_content_area' );
    
    	 generate_construct_sidebars();
    
    get_footer();
    

    and i want to insert this code
    <?php wp_tag_cloud('number=100'); ?>

    how to insert wp tag cloud code to the template page, i mean where i should place the code.

    thank you

    GP Premium 1.5.6
    #504641
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    It depends where you want it to show up.

    Currently that template will grab the code from the content-page.php file in the parent theme.

    If you copy that file into your child theme and change it to content-tags.php, then change this line:

    get_template_part( 'content', 'page' );

    To this:

    get_template_part( 'content', 'tags' );

    Then add the code you want into the content-tags.php file wherever you want it to display.

    #504785
    Feri

    i want to place the code and show up tag cloud at main content area

    screenshot: https://prnt.sc/ijbdml

    try to copy paste the code like this

    
    <div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    		    <?php wp_tag_cloud('number=100'); ?>

    but the result, tag cloud display out off main content area.

    #504908
    Tom
    Lead Developer
    Lead Developer

    You would have to add it to the template I explained above.

    All of the inner content stuff is inside the content-xx.php template.

    #504954
    Feri

    take a long long time to understand what you explained above. my bad :)))

    and finally…

    thank you again for your support.

    #505349
    Tom
    Lead Developer
    Lead Developer

    It was complicated! Glad I could help 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.