Custom Fields Duplicating Themselves (Not using a plugin to create them)
-
My problem is this… When I direct WordPress to create a custom field, via either the built-in post edit screen or via a custom post edit screen, they don’t initially show when the “Add Custom Field” button is clicked. Additionally, when I refresh the post edit screen, the custom fields appear in the “Custom Fields” box and at least two or more duplicate fields of the same name and values appear. I have no plugins installed and have reinstalled WordPress in an attempt to resolve the issue. All of my attempts to fix the issue have been unsuccessful and I have been unable to locate a thread that addresses the same issues I am having.
The theme I am working with is completely custom and aside from a walker class for bootstrap navigation, I am not using any theme frameworks that may have code that would interfere with WordPress. Below is my functions.php file for reference just in case something I have coded is the issue.
Please keep in mind that this theme is in development and being built using XAMPP and VSCode on my local system.
Any help would be appreciated.
<?php //Adding theme supportsß function tdcsociety_theme_support() { add_theme_support( 'html5'); add_theme_support( 'post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ] ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'custom-background' ); add_theme_support( 'custom-header' ); add_theme_support( 'custom-logo' ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'customize-selective-refresh-widgets' ); } add_action( 'after_setup_theme', 'tdcsociety_theme_support' ); ?> <?php //Adding support for CSS styles function tdcsociety_enqueue_styles() { wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/assets/css/bootstrap.min.css', [], time(), 'all' ); wp_enqueue_style( 'lightbox', get_stylesheet_directory_uri() . '/assets/css/lightbox.css', [], time(), 'all' ); wp_enqueue_style( 'main', get_stylesheet_directory_uri() . '/style.css', [], time(), 'all' ); } add_action( 'wp_enqueue_scripts', 'tdcsociety_enqueue_styles'); ?> <?php //Adding support for Javascript function tdcsociety_enqueue_scripts() { wp_enqueue_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js', [], time(), true ); wp_enqueue_script( 'lightbox', get_stylesheet_directory_uri() . '/assets/js/lightbox.js', [], time(), true ); wp_enqueue_script( 'popper-js', 'https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js', [], time(), true ); wp_enqueue_script( 'bootstrap', get_stylesheet_directory_uri() . '/assets/js/bootstrap.min.js', [], time(), true ); wp_enqueue_script( 'accordion', get_stylesheet_directory_uri() . '/assets/js/accordion.js', [], time(), true ); wp_enqueue_script( 'hideseek', get_stylesheet_directory_uri() . '/assets/js/jquery.hideseek.js', [], time(), true ); wp_enqueue_script( 'theme-js', get_stylesheet_directory_uri() . '/assets/js/scripts.js', [], time(), true ); } add_action( 'wp_enqueue_scripts', 'tdcsociety_enqueue_scripts'); ?> <?php /* * Register a custom menu page. */ function wpdocs_register_my_custom_menu_page() { add_menu_page( __( 'Membership', 'tdcsociety' ), 'Membership', 'manage_options', 'index.php/members', '', 'dashicons-groups', 5 ); } add_action( 'admin_menu', 'wpdocs_register_my_custom_menu_page' ); ?> <?php /* * Register Custom Post Types */ function tdcsociety_register_my_post_types () { $labels_members = array( 'name' => __('Members', 'tdcsociety') ); $args_members = array( 'labels' => $labels_members, 'description' => 'A collection of the societies members', 'show_in_menu' => 'index.php/members', 'public' => true, 'has_archive' => true, 'show_in_rest' => true, 'show_ui' => true, 'hierarchical' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'custom-fields', 'post-formats', 'excerpt', 'revisions'), 'taxonomies' => array('category', 'post_tag'), 'rewrite' => array('slug' => 'members'), ); $labels_board = array( 'name' => __('Board of Supervisors', 'tdcsociety') ); $args_board = array( 'labels' => $labels_board, 'description' => 'A collection of the societies members on the Board of Supervisors', 'show_in_menu' => 'index.php/members', 'public' => true, 'has_archive' => true, 'show_in_rest' => true, 'show_ui' => true, 'hierarchical' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'custom-fields', 'post-formats', 'excerpt', 'revisions'), 'taxonomies' => array('category', 'post_tag'), 'rewrite' => array('slug' => 'board_of_supervisors'), ); $labels_judicial = array( 'name' => __('Judicial Advisory Board', 'tdcsociety') ); $args_judicial = array( 'labels' => $labels_judicial, 'description' => 'A collection of the societies members on the Steering Committee', 'show_in_menu' => 'index.php/members', 'public' => true, 'has_archive' => true, 'show_in_rest' => true, 'show_ui' => true, 'hierarchical' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'custom-fields', 'post-formats', 'excerpt', 'revisions'), 'taxonomies' => array('category', 'post_tag'), 'rewrite' => array('slug' => 'judicial_advisory_board'), ); register_post_type('members', $args_members); register_post_type('board_of_supervisors', $args_board); register_post_type('steering_committee', $args_judicial); } add_action('init', 'tdcsociety_register_my_post_types'); ?> <?php //Sets the title tag seperator function tdcsociety_set_document_title_separator ($sep){ return ('|') ; } add_filter ('document_title_separator','tdcsociety_set_document_title_separator') ; //defines path to theme root folder so images display properly. define( 'THEME_IMG_PATH', get_stylesheet_directory_uri() . '/' ); ?> <?php //Registering Navigation Menus if (! function_exists( 'tdcsociety_register_nav_menu' )) { function tdcsociety_register_nav_menu() { register_nav_menus(array( 'primary' => __('Primary', 'tdcsociety'), )); } add_action('after_setup_theme', 'tdcsociety_register_nav_menu', 0); } ?> <?php /* * Register Custom Navigation Walker */ function register_navwalker(){ require_once get_template_directory() . '/class-wp-bootstrap-navwalker.php'; } add_action( 'after_setup_theme', 'register_navwalker' ); ?>
The topic ‘Custom Fields Duplicating Themselves (Not using a plugin to create them)’ is closed to new replies.