• Resolved BlackStar

    (@blackstar1991)


    I added custom post type for template. Into functions.php

    add_action( 'init', 'true_register_post_type_init' );
    function true_register_post_type_init() {
    
        $labels = array(
            'name' => 'Публікації',
            'singular_name' => 'Публікація',
            'add_new' => 'Додати публікацію',
            'add_new_item' => 'Додати публікацію',
            'edit_item' => 'Редагувати публікацію',
            'new_item' => 'Нова публікація',
            'all_items' => 'Всі публікації',
            'search_items' => 'Шукати публікації',
            'not_found' =>  'Публікації в таких видах не знайдено',
            'not_found_in_trash' => 'В корзині таких публікацій не знайдено',
            'menu_name' => 'Публікації'
        );
    
        $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => false,
            'has_archive' => false,
            'menu_icon' => 'dashicons-email-alt2',
            'menu_position' => 5,
            'supports' => array( 'title', 'editor', 'custom-fields' ),
            'taxonomies' => 'category',
        );
    
        register_post_type( 'publications', $args );
    }

    Now I’m getting a warning in the template

    Warning: foreach() argument must be of type array|object, string given in D:\OSPanel\domains\redwerk-test.loc\wp-includes\class-wp-post-type.php on line 699

    I find the same problem in this topic but don’t undestand how to fix it. Can you help me please?

Viewing 1 replies (of 1 total)
  • Hi there!

    Could you try to format your labels same as the examples from this post?

    Also, if the warning message doesn’t go away, you may want to add your custom post type using a plugin. Here’s a post of our guide.

    I hope this helps. Please let us know if we can assist you further.

    Regards,
    Karla

Viewing 1 replies (of 1 total)

The topic ‘Problem with custom post type’ is closed to new replies.