I am developing a wordpress theme. In the "Menus" there is a section:
How can I add an item to this programmatically? is it possible?
Update:
If that is not possible, how can I add "icon" and "open in new tab" options.
I've searched a lot but didn't find anything. Can anybody introduce a source?
My Answer:
array
To add an item to an array in PHP, you can use the array_push() function or simply use the square brackets notation. Here are examples of both methods:
Using array_push():
php
$fruits = array("apple", "banana", "orange");
array_push($fruits, "grape");
print_r($fruits);
Using square brackets notation:
php
$fruits = array("apple", "banana", "orange");
$fruits[] = "grape";
print_r($fruits);
Both of these methods will add the item "grape" to the end of the $fruits array.
Rate this post
5 of 5 based on 8152 votesComments