0

I want to add an item to my WordPress admin menu - "News" - it's to contain a list of articles written about my company.

Each article will consist of the following metadata:

  • Headline
  • Date
  • Link to article (always an external URL)
  • Teaser text (typically 1-2 sentences from the article)
  • Publication logo (ie, Forbes, The New York Times)

None of the items in News will link to an actual page on my site, but I'd like the ability to loop through and output the list metadata on any page.

My main question is: how do I add "News" to the WordPress admin menu without creating a custom post type (and preferably without relying on a plugin)?

Upon clicking "News" in the admin menu, I'd like an edit screen to load, similar to the one used for Posts, Pages, etc.

I've tried using the add_menu_page hook, like so:

function register_my_custom_menu_page(){
    add_menu_page( 'News', 'News', 'add_news', 'metaboxes/events_meta.php', '', get_home_url() .'/wp-content/themes/my_theme/assets/img/logo.png',  );
}

But end up with a completely blank screen containing the word date. How do I ensure I still within the context of the WP admin menu?

Once I figure out the best approach for adding News to the admin menu, my plan is to use WPAlchemy for the metaboxes. I would like to avoid using Advanced Custom Fields.

Any insights would be greatly appreciated.

  • You've got A LOT of work ahead of you to try and replicate all the functionality of posts if you don't want it to be a custom post type. Is there any reason why? – Andrew Bartel Nov 12 '14 at 20:28
1

You could do it with something like this in theme functions.php (at end)

add_action('admin_menu', 'news_admin_test');
function news_admin_test() {
    add_menu_page( 'News Page Title', 'News Option', 'manage_options', 'newspage', 'show_menu_news', get_home_url() .'/wp-content/themes/my_theme/assets/img/logo.png' );
}

function show_menu_news () {
    echo 'News content';
}
  • Yes, this is more or less what I first attempted. But I don't want a blank screen to load, I want to use wp-admin/edit.php, which is what Posts and Pages point to, but not sure how to do that with my News list, since it isn't a custom post type. – andrw22 Nov 12 '14 at 19:47
  • well I think all data that you need could fit in WP-post fields and a "News" taxonomy. This way you could have a separated admin menu that shows News and adjust template or widget to just show any field. More info here and here – gonzalezea Nov 12 '14 at 20:35

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.