1

I've been writing wordpress themes for years now and am kind of getting bored of copy-pasting the same bunch of code for archive titles.

Let's say I have 1 template for yearly and monthly archives, categories, tag archives, etc. I have a copypasta that spans like 40 lines and is basically a huge if/else thing which generates the relevant heading.

Is there something more sane/quick to build the heading text?

  • Could you please file an edit and show the code that you are currently using? Thanks. – kaiser Jul 14 '14 at 12:09
0

You could create your own template function which you reuse instead of copy&paste. Basically put something like this in your functions.php

function my_theme_archive_header(){
    echo "Custom header output";
}

Then you just put a call to this function in your template.

my_theme_archive_header();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.