WordPress.org

Ready to get started?Download WordPress

Forums

WP 2.0 and my-hacks.php (archive menu dropdown) (12 posts)

  1. Harvey
    Member
    Posted 8 years ago #

    New WP Site here! http://www.japannewbie.com/blog/

    I just moved my blog from MT to WP, and
    wanted to implement the dropdown menu
    for archives and categories that I see on
    http://www.tokyotimes.org

    How did they do that?

    Do you think they are using this feature?
    http://www.qwghlm.co.uk/blog/?p=740

    Will this also work with WP2.0?

    How does one enable my-hacks.php in WP2.0?

    Thanks for any tips on this one!

  2. Austin Matzko
    Member
    Posted 8 years ago #

    You can enable my-hacks.php under Options > Miscellaneous, but I recommend that you either put into a plugin the function mentioned at http://www.qwghlm.co.uk/blog/?p=740 , or even easier, include it in a file named functions.php and put it in your theme's folder (along with index.php, sidebar.php, header.php, etc).

  3. tauquil
    Member
    Posted 8 years ago #

    I've got a similar feature at my blog. Try adding the following code to where you want the dropdown menu to appear (if you don't mind using Javascript):

    <form name="archiveform" action="">
    <select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">
    <option value=''>Select Month:</option>
    <?php wp_get_archives('format=option'); ?>
    </select>
    </form>

  4. Harvey
    Member
    Posted 8 years ago #

    Thanks for the tips!

    I have never created a plugin on my own.

    Is it as simple as...

    1. Creating a file called functions.php

    2. Copy and paste the code from http://www.qwghlm.co.uk/blog/?p=740 into functions.php

    3. Go to "plugins" in the WP interface select it, activate it, and off I go?

    Thanks for this!

  5. Austin Matzko
    Member
    Posted 8 years ago #

    Harvey, here's what you need to do--you don't have to create a plugin. Copy all the code at http://www.qwghlm.co.uk/blog/?p=740 (from function make_month_dropdown() {
    to
    echo '</div></form>';
    }

    and paste it into a file named functions.php, which you'll put in your theme's folder. Note: you've also got to put <?php at the very beginning of the file and ?> at the end.

    Then, as it says on that page, look in your theme's files for something like
    <?php get_archives(); ?>
    and replace it with
    <?php make_month_dropdown(); ?>
    In the WordPress "Classic" theme, <?php get_archives(); ?> is found in the file sidebar.php.

  6. Harvey
    Member
    Posted 8 years ago #

    Thanks for that!

    In the POOL theme, sidebar.php using a function call like this...

    <?php wp_get_archives('type=monthly&show_post_count=1'); ?>

    Instead of <?php get_archives(); ?>

    I believe it is the same though, and replaced that line with
    <?php make_month_dropdown(); ?>

    As you suggested.

    I also created function.php with the code on the site, plus the opening and closign PHP tags.

    However, when I upload both to the themes directory, I get an error from sidebar.php.

    Fatal error: Call to undefined function: make_month_dropdown() in /usr/www/users/jnewbie/blog/wp-content/themes/pool/sidebar.php on line 50

    Seems that even though function.php is up there, the function isn't being found?

  7. Austin Matzko
    Member
    Posted 8 years ago #

    It needs to be functions.php with the "s," not function.php.

  8. Harvey
    Member
    Posted 8 years ago #

    Worked like a charm. Thanks filosofo, I really appreciate it!

  9. wufpup
    Member
    Posted 8 years ago #

    filosofo, i've tried the same thing, trying your suggestions, and I get the following error:

    Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/.honor/obscure/defenestrate.org/wp-content/themes/fastlane/functions.php on line 20

    could this be something specific to the WP 2.0 theme i'm using?

    I created the functions.php file in the root folder of my theme and inserted the PHP codr in there. any ideas?

    According to DreamWeaver, line 20 is:
    echo "<option value="$thisM"";

    I'd appreciate any information you might have.

    -Nick

  10. rdsmes
    Member
    Posted 8 years ago #

    Nick -

    I think that line has a few too many double-quotes in it. Try either:
    echo "<option value=$thisM";
    or
    echo '<option value='.$thisM;

  11. wufpup
    Member
    Posted 8 years ago #

    thanks a million rdsmes,

    that's what it was!

    (i'm more of a coldfusion programmer, not a php kinda guy, so thanks again)

    -Nick

  12. ebrito
    Member
    Posted 8 years ago #

    Does anybody know how to do the same with categories, recent posts and commets?

    Tank you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags