Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Wordpress Theme Option page


I have a problem with this code:

function register_my_custom_menu_page() {
    add_menu_page( 'Slim option', 'Slim option', 'manage_options', get_template_directory_uri() . '/assets/admin/theme-admin.php', '', get_template_directory_uri() . '/assets/img/icon.png', 99 );
add_action( 'admin_menu', 'register_my_custom_menu_page' );

I am working local with Mamp and i get this output: http://localhost/localhost/slim/wp-content/themes/slim/assets/admin/theme-admin.php

I use the same method with all my css files with out any problems.

4 Answers

Andrew McCormick
Andrew McCormick
17,730 Points

I've never seen it do that before. Is it outputting the same when you call it the second time for you .png file?

have you tried using get_stylesheet_directory_uri() instead just to see what you get (assuming you don't have child theme for this theme active)

I have tried with it too, with the same result. I think maybe it's something with my MAMP settings.

Jon W
Jon W
6,185 Points

Have you tried not using get_template_directory_uri() at all and just use the relative path?

Is this code in functions.php or a plugin folder?

The relative path goes til wp-admin/.

This is in functions.php