This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Custom Tag and Category Pages – How To Make?

  • Creator
    Topic
  • #16572
    jimh009
    Participant

    Hi,

    I need to be able to put in a paragraph or two of text at the top of each “tag” or “category” archive page. The text will be different for each tag/category. I expect to have at least 100+ tags for the site once I’ve completed moving it over from the current static site. I’m using the latest version of Alyeska and using the Child Theme.

    My question is…how do I make these custom tag/category pages? I was reading through the tag template page over on WordPress Codex (http://codex.wordpress.org/Tag_Templates) and followed the instructions which seemed easy enough, but it didn’t work. I created a tag.php page (based on the archive.php page in Alyeska) and uploaded it to the child theme, but it didn’t change anything. I also created a tag-slup.php page (also based on the archive.php page which I then renamed tag-apple-teas.php) and that didn’t work, either. Nothing crashed or anything – just nothing happened!

    I do not need to do anything “fancy” with the custom tag/category archive pages. Just put in a paragraph or two of text that will appear on the top of the tag/archive page – right above the first post . Basically, the paragraphs I’ll be inserting is just a H1 Header and some “introductory” text for each tag – to explain it more.

    While not mandatory, I’d also like to slightly modify the presentation of the posts shown on the tag archive page too. Basically, I’d like to get rid of the date/author/tags/category information that is currently shown by default for each post. Really, I’d like nothing more than the post title and the post excerpt and the little comment box shown – with nothing else. I’d also like to get rid of the 30 post limit, too.

    This is the tag archive post I was attempting to modify on my site.

    http://www.teadiscussion.com/wordpress/tag/apple-teas/

    Thanks

    Jim

    PS – I did a search of the forum, and I did see a few results that looked like it might answer my questions. But they were for another theme, and thus I couldn’t see the answers. Since Alyeska is based on the same framework for your other themes, you might consider getting rid of this kind of annoying feature of your support forum and allowing any registered user to see “answers” for any theme – removing the restriction of only being able to see the answers for a specific theme. Not being able to see the answers make the forum search kind of useless! Anyways, just my two cents.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #16579
    Jason Bobich
    Keymaster

    Hello,

    These are customizations you’ll need to make from your child theme. I’ll try to get you going in the right direction.

    My question is…how do I make these custom tag/category pages? I was reading through the tag template page over on WordPress Codex (http://codex.wordpress.org/Tag_Templates) and followed the instructions …

    This should all work fine. There’s nothing in the theme does any kind of filtering on how WordPress’s template hierarchy works. Anyway, so I’m not sure what could be the issue there in what you’re doing.

    But with that said, these main template files like archive.php can change quite often with theme updates. And since they hold the entire structure of the current page, this can open up higher risk of messy-ness later on.

    This is why it’s good to utilize all the action hooks that the theme gives you.

    http://dev.themeblvd.com/tutorial/actions/

    http://dev.themeblvd.com/tutorial/primary-framework-action-hooks/

    Hopefully, this will get you started from your child theme’s functions.php:

    /**
     * Tag Archive Header
     */
    function my_tag_headers() {
    
    	// Check if we're on a tag archive page
    	if ( is_tag() ) {
    
    		// Display Title of tag
    		echo '<h1>'.single_tag_title('', false).'</h1>';
    
    		// Display Description of tag
    		echo tag_description();
    
    	}
    }
    add_action( 'themeblvd_content_top', 'my_tag_headers' );

    So, in your WP admin, under Posts > Tags, this would pull the title and description setup there.

    Here’s docs for some of the functions I used above:

    https://codex.wordpress.org/Function_Reference/is_tag

    https://codex.wordpress.org/Function_Reference/single_tag_title

    https://codex.wordpress.org/Function_Reference/tag_description

    While not mandatory, I’d also like to slightly modify the presentation of the posts shown on the tag archive page too. Basically, I’d like to get rid of the date/author/tags/category information that is currently shown by default for each post…

    You’d copy the content part, content-archive.php to your child theme, and modify it to your needs. This file contains the setup for each individual post shown in the listing of posts on the archive pages.

    http://dev.themeblvd.com/tutorial/editable-content-files/

    Note: Contrary to action hooks, in this case, the inclusion of these template parts give you another way to make edits to a file like archive.php via a simpler file that is less likely to change with updates. And if it does, it won’t have as much as of adverse impact, and it’s easier to look in it, and see what’s changed.

    I’d also like to get rid of the 30 post limit, too.

    The theme doesn’t alter any of the default WordPress queries for handling these archive pages. But maybe I’m misunderstanding what you mean because you’re saying there’s currently a 30 post limit? The number of posts per page that should show on any of your archive pages should be what’s set in your WP admin at Settings > Reading > Blog pages show at most.

    Is this not the case?

    PS – I did a search of the forum, and I did see a few results that looked like it might answer my questions. But they were for another theme, and thus I couldn’t see the answers…

    Apologies, but unfortunately this probably isn’t ever going to change. You’re definitely not the first to bring this up, nor the last. However, it’s very important that buyers only have access to the support forums belonging to the themes they’ve purchased for reasons I don’t really want to discuss publicly.

    What I do want though, however, is to improve search tremendously so you only get results only for the theme you select. I am all for improving the way this site works to make things as easy for buyers as possible, but unfortunately it is not feasible to increase access to products not purchased.

    #16580
    Jason Bobich
    Keymaster

    Expanded above example for both categories and tags. —

    /**
     * Tag/Category Archive Header
     */
    function my_archive_header() {
    	if ( is_tag() ) {
    		echo '<h1>'.single_tag_title('', false).'</h1>';
    		echo tag_description();
    	} else if ( is_category() ) {
    		echo '<h1>'.single_cat_title('', false).'</h1>';
    		echo category_description();
    	}
    }
    add_action( 'themeblvd_content_top', 'my_archive_header' );
    #16586
    jimh009
    Participant

    Hi Jason,

    You’re the man! Thanks…the code put into the functions.php file of the child theme worked perfectly. Better yet, doing it this way makes my life sooooooo much easier. I thought I might end up having a new custom file for every tag.

    One question I have is how to format the background where the H1 and tag/category description show. Right now, the H1 and text (from the tag description) lays out on the default gray background. It would be very nice if the H1 and text was laid out in the “article wrap” white box that goes around normal posts and the individual articles throughout the theme. See this page to see what I mean.

    http://www.teadiscussion.com/wordpress/tag/apple-teas/

    I used Firebug and saw the div classes you used (“article-wrap”), so I tried wrapping the code you provided above within the div tags. But all I succeeded in doing was crashing the site (parse error)! How can I go about getting the H1 and tag description (and category description too) to appear within that nice white article-wrap that you use throughout Alyeska??

    Never mind the 30 post limit thing. I screwed up the terminology – I’m still new to WordPress – and adjusted what I needed to in the WP dashboard.

    I haven’t played with the content-archive.php yet, but thanks for the info. I’ll give it a try in the next few days and let you know if I succeed or fail in modifying it to my needs. But your instructions looks simple enough.

    #16587
    Jason Bobich
    Keymaster

    You’re just echoing out whatever HTML you want to show as a string. If I do:

    echo 'This is a string';

    … with single quotes, whatever is in between the single quotes is going to print into the page. So, if I want HTML markup in there, I can do that, the same way.

    echo '<div class="whatever">Stuff...</div>';

    So, for example:

    /**
     * Tag/Category Archive Header
     */
    function my_archive_header() {
    	if ( is_tag() || is_category() ) {	
    
    		echo '<div class="boxed-layout">';
    		echo '<div class="boxed-layout-inner">';
    
    		if ( is_tag() ) {
    			echo '<h1>'.single_tag_title('', false).'</h1>';
    			echo tag_description();
    		} else if ( is_category() ) {
    			echo '<h1>'.single_cat_title('', false).'</h1>';
    			echo category_description();
    		}
    		
    		echo '</div>';
    		echo '</div>';
    	}
    }
    add_action( 'themeblvd_content_top', 'my_archive_header' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The forum ‘Alyeska Responsive WordPress Theme’ is closed to new topics and replies.