admin管理员组文章数量:1425385
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.
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.
Share Improve this question edited Nov 12, 2014 at 18:23 Pieter Goosen 55.4k23 gold badges116 silver badges210 bronze badges asked Nov 12, 2014 at 18:17 andrw22andrw22 611 silver badge9 bronze badges 1- 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 Commented Nov 12, 2014 at 20:28
1 Answer
Reset to default 1You 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';
}
本文标签: wp queryHow do I add an item to the WP admin menu
版权声明:本文标题:wp query - How do I add an item to the WP admin menu? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745445256a2658634.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论