Site logo

Archived topic

Create Page Templates For Tag Archive

5 replies · Started by Feri on February 24, 2018

Viewing posts 1–6 of 6

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

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.

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.

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.

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

and finally...

thank you again for your support.

It was complicated! Glad I could help :)

This archived topic is closed to new replies.