Add New items in the buddy member menu


<?php 
function my_setup_nav() {
      global $bp;

      bp_core_new_nav_item( array( 
            'name' => __( 'Item One', 'buddypress' ), 
            'slug' => 'my-item-one', 
            'position' => 30, 
            'screen_function' => 'my_item_one_page', 
      ) );

      bp_core_new_nav_item( array(
            'name' => __( 'Item Two', 'buddypress' ),
            'slug' => 'my-item-two',
            'position' => 20,
            'screen_function' => 'my_item_two_template' 
      ) );

      // Change the order of menu items
      $bp->bp_nav['settings']['position'] = 100;

      // Remove a menu item
      $bp->bp_nav['activity'] = false;

      // Change name of menu item
      $bp->bp_nav['groups']['name'] = 'community';
}

add_action( 'bp_setup_nav', 'my_setup_nav' );


// Load a page template for your custom item. You'll need to have an item-one-template.php and item-two-template.php in your theme root.
function my_item_one_template() {
      bp_core_load_template( 'item-one-template' );
}

function my_item_two_template() {
      bp_core_load_template( 'Sign-Up' );
}


?>



Advertisements

WordPress custom post with custom fields

wordpress-custom-post

In the wordpress there need to create certain code that can create the custom post. The custom post help in custom development.
With the help custom post you easily add the different module like portfolio, books, movie etc. The wordpress provides to you various inbuilt functions that can increase you development faster and robust. Today i show you just management of simple portfolio items. In this context i show you with custom post type you can add the custom text box also. That custom text help them to refining your post. With the help of these custom field you can filter your matter better. I just show the below code.

<?php

add_action(‘init’, ‘portfolio_register’);

function portfolio_register() {

$labels = array(
‘name’ => _x(‘My Portfolio’, ‘post type general name’),
‘singular_name’ => _x(‘Portfolio Item’, ‘post type singular name’),
‘add_new’ => _x(‘Add New’, ‘portfolio item’),
‘add_new_item’ => __(‘Add New Portfolio Item’),
‘edit_item’ => __(‘Edit Portfolio Item’),
‘new_item’ => __(‘New Portfolio Item’),
‘view_item’ => __(‘View Portfolio Item’),
‘search_items’ => __(‘Search Portfolio’),
‘not_found’ =>  __(‘Nothing found’),
‘not_found_in_trash’ => __(‘Nothing found in Trash’),
‘parent_item_colon’ => ”
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘query_var’ => true,
‘menu_icon’ => get_stylesheet_directory_uri() . ‘/article16.png’,
‘rewrite’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => array(‘title’,’editor’,’thumbnail’)
);

register_post_type( ‘portfolio’ , $args );
}

register_taxonomy(“Skills”, array(“portfolio”), array(“hierarchical” => true, “label” => “Skills”, “singular_label” => “Skill”, “rewrite” => true));

add_action(“admin_init”, “admin_init”);

function admin_init()
{
add_meta_box(“year_completed-meta”, “Year Completed”, “year_completed”, “portfolio”, “side”, “low”);
add_meta_box(“credits_meta”, “Design &amp; Build Credits”, “credits_meta”, “portfolio”, “normal”, “low”);
}

function year_completed(){
global $post;
$custom = get_post_custom($post->ID);
$year_completed = $custom[“year_completed”][0];
?>
<label>Year:</label>
<input name=”year_completed” value=”<?php echo $year_completed; ?>” />
<?php
}

function credits_meta() {
global $post;
$custom = get_post_custom($post->ID);
$designers = $custom[“designers”][0];
$developers = $custom[“developers”][0];
$producers = $custom[“producers”][0];
?>
<p><label>Designed By:</label><br />
<textarea cols=”50″ rows=”5″ name=”designers”><?php echo $designers; ?></textarea></p>
<p><label>Built By:</label><br />
<textarea cols=”50″ rows=”5″ name=”developers”><?php echo $developers; ?></textarea></p>
<p><label>Produced By:</label><br />
<textarea cols=”50″ rows=”5″ name=”producers”><?php echo $producers; ?></textarea></p>
<?php
}

?>

<?php

//add_meta_box( $id, $title, $callback, $page, $context, $priority );

global $post;

$custom = get_post_custom($post->ID);

add_action(‘save_post’, ‘save_details’);

function save_details(){
global $post;

update_post_meta($post->ID, “year_completed”, $_POST[“year_completed”]);
update_post_meta($post->ID, “designers”, $_POST[“designers”]);
update_post_meta($post->ID, “developers”, $_POST[“developers”]);
update_post_meta($post->ID, “producers”, $_POST[“producers”]);
}

add_action(“manage_posts_custom_column”,  “portfolio_custom_columns”);
add_filter(“manage_edit-portfolio_columns”, “portfolio_edit_columns”);

function portfolio_edit_columns($columns){
$columns = array(
“cb” => “<input type=’checkbox’ />”,
“title” => “Portfolio Title”,
“description” => “Description”,
“year” => “Year Completed”,
“skills” => “Skills”,
);

return $columns;
}
function portfolio_custom_columns($column){
global $post;

switch ($column) {
case “description”:
the_excerpt();
break;
case “year”:
$custom = get_post_custom();
echo $custom[“year_completed”][0];
break;
case “skills”:
echo get_the_term_list($post->ID, ‘Skills’, ”, ‘, ‘,”);
break;
}
}

//’supports’ => array(‘title’, ‘editor’, ‘thumbnail’);

add_theme_support(‘post-thumbnails’);

register_post_type( ‘portfolio’ , $args );
flush_rewrite_rules();

?>

Add items in menu item in wordpress

This is simple code i tell you step by step

<?php
/*
Plugin Name: Insert Page in admin menu
Plugin URI: https://rakeshkumar125.wordpress.com
Description: This plugin shows you how to add page in admin menu
Author: Rakesh Kumar
Author URI: https://rakeshkumar125.wordpress.com
*/

// Hook for adding admin menus
add_action(‘admin_menu’, ‘mt_add_pages’);

// action function for above hook
function mt_add_pages() {

// Add a new top-level menu (ill-advised):
add_menu_page(__(‘Your Menu Title’), __(‘Your Menu name’), ‘manage_options’, ‘mt-top-level-handle’, ‘mt_toplevel_page’ );

}

// mt_toplevel_page() displays the page content for the custom Test Toplevel menu
function mt_toplevel_page() {
echo ”
” . __( ‘page contents for the menu’ ) . ”
“;
}

?>