Created
December 10, 2012 18:15
-
-
Save donnykurnia/4252244 to your computer and use it in GitHub Desktop.
Wordpress menu generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import socialniho menu | |
$top = new Menu('Top menu'); | |
// page link | |
if ($page = get_page_by_path('some-page')) { | |
$top->title('Page'); | |
$top->object_id($page->ID); | |
$top->object('page'); | |
$top->type('post_type'); | |
$top->save(); | |
} else { | |
throw new Exception('Stranka nálepky neexistuje'); | |
} | |
// custom post example | |
$top->title('Title')->url('/url')->description('Some link')->save(); | |
$top->title('URL')->url('http://www.URL.com/')->description('Desc')->target('_blank')->save(); | |
// categories | |
$cat_parent_id = $top->title('Categories')->url('/clanky')->save(); | |
foreach (get_categories() as $category) { | |
$top->parent_id($cat_parent_id); | |
$top->title($category->name); | |
$top->description($category->description); | |
// link to objects | |
$top->object_id($category->term_id); | |
$top->object('category'); | |
$top->type('taxonomy'); | |
$top->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment