wordpress

WordPress create custom dashboard widget

WordPress custom dashboard widget

dashboard widget

 

Related topics

ref: https://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget

  Like
By bm on June 22, 2016 | wordpress | A comment?
Tags: , , ,

WordPress create custom widget

How to create WordPress create custom widget

Add the following code in functions.php

Admin view (Appearance->widget)

widget admin

 

Front end view

front end

 

ref:

https://codex.wordpress.org/Widgets_API

https://developer.wordpress.org/reference/functions/format_to_edit/

https://codex.wordpress.org/Function_Reference/_2

 

  Like

WordPress get menu array

How to get the wordpress menu array

menu structure

BY SlUG

BY LOCATION

Output

  • If the menu_item_parent equals 0 (false) that manse that menu is a root menu
  • menu_item_parent hold the parent menu id if it is not 0

 

ref: https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_object

https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/

  Like
By bm on | wordpress | A comment?
Tags: ,

WordPress custom menu

How to create WordPress custom menu

Step 1. register_nav_menu()

In functions.php add the following code

I after adding this code the new menu will started showing in admin (Appearance->menu)

wordpress custome menu admin

We can register multiple menus at same time

Step 2. wp_nav_menu()

Call ‘ wp_nav_menu()’ wherever you want to display the newly created menu

I am just adding in footer.php

 

new menu in footer

 

ref: https://codex.wordpress.org/Function_Reference/register_nav_menu

ref : https://codex.wordpress.org/Function_Reference/register_nav_menus

  Like
By bm on | wordpress | A comment?
Tags: ,

wordpress create REST Api

Example 1

Example 2 – Passing parameter

Example 3 – Passing multiple parameters

Example 3- permission check

 

$request in call back method is an object of ‘WP_REST_Request’ class this class contains methods like

get_header($key)

get_headers()

get_method()

etc.

we can call these methods with the help of $request  object eg:- $request->get_headers()

 

 

Ref: https://developer.wordpress.org/reference/functions/register_rest_route/

1 Like
By bm on June 9, 2016 | wordpress | 2 comments

WordPress create custom Page Templates

Custom page with minimum requirement

keep the template file inside your /wp-content/themes/{your theme folder}/

Here the commented part is very important “/* Template Name: min Custom Page */”

this Template name will be displayed in template selection dropdown

custom_page

 

Little bit advanced version. Here I have added Author details, date, edit link, Category, comments, next and previous post links

 

  Like
By bm on May 12, 2016 | wordpress | A comment?