Friday, June 8, 2018

Wordpress function repos

/* get featured img url */

function featured_img_url() {
	$thumb_id = get_post_thumbnail_id();
	$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
	$thumb_url = $thumb_url_array[0];
	
	return $thumb_url;
}

/* get post slug (machine name) */

function get_post_slug() {
	global $post;
	$slug = $post->post_name;
	
	return $slug;
}

/* get menu items based on menu's machine name */

function mobile_menu_items($menu_machine_name){
	$menu_name = $menu_machine_name;
	$locations = get_nav_menu_locations();
	$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
	$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
	
	$menu_group = '

No comments:

Post a Comment