Forum Replies Created

Viewing 15 replies - 31 through 45 (of 52 total)
  • Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz . I am confused. If I use update_post_meta() where meta field for the post does not exist, then where should I use add_post_meta() ?

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz .

    I have 3 fields like below image.

    https://i.stack.imgur.com/pFq4Z.png

    Should I use below code ?

    if (isset($_POST[‘name’])) {
    update_post_meta($post_id, ‘name’, sanitize_text_field($_POST[‘name’]));
    }

    if (isset($_POST[‘address’])) {
    update_post_meta($post_id, ‘address’, sanitize_text_field($_POST[‘address’]));
    }

    if (isset($_POST[‘phone’])) {
    update_post_meta($post_id, ‘phone’, sanitize_text_field($_POST[‘phone’]));
    }

    Is there any way to Save multiple metabox values ?

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @threadi . Yes, there is still a problem. The submenu item “API Key” is working. But I would like to make the list available as another submenu item of “News Info”.

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @threadi . Yes, I want to have such an expanding menu.

    My custom post type registration code is like below

    
    public function register_custom_post_type () {
    
            $supports = array('title');
    
            $labels = array(
                'name' => _x('Newss', 'plural'),
                'singular_name' => _x('News', 'singular'),
                'name_admin_bar' => _x('News', 'admin bar'),
                'add_new' => _x('Add New', 'add new'),
                'add_new_item' => __('Add New News'),
                'new_item' => __('New News'),
                'edit_item' => __('Edit News'),
                'view_item' => __('View News'),
                'all_items' => __('All Newss'),
                'search_items' => __('Search News'),
                'not_found' => __('No News Found.'),
            );
    
            $args = array(
                'supports' => $supports,
                'labels' => $labels,
                'public' => true,
                'description' => 'News Information',
                'has_archive' => true,
                'exclude_from_search' => false,
                'show_in_menu' => 'edit.php?post_type=news'
            );
    
            register_post_type('news', $args);
        }
    

    My Menu code is like below

    
    public function admin_menu()
    {
        add_menu_page(‘News Information’, ‘News Info’, ‘manage_options’, ‘news_info’, [$this, ‘api_key_page’], ‘dashicons-info-outline’, 30);
        add_submenu_page(‘news_info’, ‘News Information’, ‘API Key’, ‘manage_options’, ‘news_info_page’, [$this, ‘api_key_page’]);
        add_submenu_page(‘news_info’, ‘News Information’, ‘News’, ‘manage_options’, ‘edit.php?post_type=news’);
        remove_submenu_page(‘news_info’, ‘news_info’);
    }
    
    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz . Yes, My CPT already have a submenu item to list news posts but I would like to attach it with another menu.

    My custom post type registration code is like below

    
    public function register_custom_post_type () {
    
            $supports = array('title');
    
            $labels = array(
                'name' => _x('News', 'plural'),
                'singular_name' => _x('News', 'singular'),
                'name_admin_bar' => _x('News', 'admin bar'),
                'add_new' => _x('Add New', 'add new'),
                'add_new_item' => __('Add New News'),
                'new_item' => __('New News'),
                'edit_item' => __('Edit News'),
                'view_item' => __('View News'),
                'all_items' => __('All Newss'),
                'search_items' => __('Search News'),
                'not_found' => __('No News Found.'),
            );
    
            $args = array(
                'supports' => $supports,
                'labels' => $labels,
                'public' => true,
                'description' => 'News Information',
                'has_archive' => true,
                'exclude_from_search' => false,
                'show_in_menu' => 'edit.php?post_type=news'
            );
    
            register_post_type('news', $args);
        }
    

    My Menu code is like below

    
    public function admin_menu()
    {
        add_menu_page(‘News Information’, ‘News Info’, ‘manage_options’, ‘news_info’, [$this, ‘api_key_page’], ‘dashicons-info-outline’, 30);
        add_submenu_page(‘news_info’, ‘News Information’, ‘API Key’, ‘manage_options’, ‘news_info_page’, [$this, ‘api_key_page’]);
        add_submenu_page(‘news_info’, ‘News Information’, ‘News’, ‘manage_options’, ‘edit.php?post_type=news’);
        remove_submenu_page(‘news_info’, ‘news_info’);
    }
    
    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @threadi . Yes, I want to make this list available as a submenu item of “News Info”. Sorry for my poor English.

    I am learning plugin development. That’s why I need coding solution. Thanks.

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @gappiah . I am learning plugin development. That’s why I need coding solution. Thanks.

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @t-p . My code is like below.

    
    

    public function admin_menu()
    {
    add_menu_page(‘News Information’, ‘News Info’, ‘manage_options’, ‘news_info’, [$this, ‘api_key_page’], ‘dashicons-info-outline’, 30);
    add_submenu_page(‘news_info’, ‘News Information’, ‘API Key’, ‘manage_options’, ‘news_info_page’, [$this, ‘api_key_page’]);
    add_submenu_page(‘news_info’, ‘News Information’, ‘News’, ‘manage_options’, ‘edit.php?post_type=news’);
    remove_submenu_page(‘news_info’, ‘news_info’);
    }`
    `

    I am getting output like below.

    https://youtu.be/NUM3GuLU_F0

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz . I would like to store additional data along with the custom post. How can I create a Custom Form with Tabs to save additional data ?

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz .

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz . I am learning WordPress plugin development. I need to insert Custom Post Type. I registered custom post type using register_post_type(). I am getting below Form when I am trying to insert a New Csutom Post Types (News).

    https://i.stack.imgur.com/ICDzD.png

    **How can I customize this Form ?**

    I would like to add some radio buttons and text fields here.

    • This reply was modified 2 years, 6 months ago by mabufoysal.
    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @bcworkz . I would like to Insert Custom Post Types using a Form like below screenshot.

    How can I do that ?

    View post on imgur.com

    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @threadi.

    Thread Starter mabufoysal

    (@mabufoysal)

    Forum: Fixing WordPress
    In reply to: Using Composer
    Thread Starter mabufoysal

    (@mabufoysal)

    Thanks @psykro

Viewing 15 replies - 31 through 45 (of 52 total)