Tusko / ACF-CPT-Options-Pages

Small addon for ACF Options. Adds ACF options page per custom post type
GNU General Public License v3.0
74 stars 15 forks source link

CPT Options saving as options_ and not cpt_ #8

Closed danimalweb closed 7 years ago

danimalweb commented 7 years ago

Great plugin, this seems really useful. I'm having trouble pulling back the saved options in the code. I checked the database and my CTP Options are saving as options_fieldname and not cpt

Any ideas how I can debug this? In the WP-Admin I have my options pages for each CPT, and the saved data is there, but it looks like it's not stored in the DB correctly.

I did a few var_dumps in the plugin code and its finding the correct CPT, just not saving as.

Cheers!

Tusko commented 7 years ago

Hi @danimalweb I have right records in database (stored in wp_options) https://cl.ly/k0iC

danimalweb commented 7 years ago

Is it possible one of the CPT args is not set correctly?

<?php
function cptui_register_my_cpts_designer_collections() {

    /**
     * Post Type: Designer Collections.
     */

    $labels = array(
        "name" => __( 'Designer Collections', 'tofino' ),
        "singular_name" => __( 'Designer Collection', 'tofino' ),
    );

    $args = array(
        "label" => __( 'Designer Collections', 'tofino' ),
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "publicly_queryable" => true,
        "show_ui" => true,
        "show_in_rest" => false,
        "rest_base" => "",
        "has_archive" => true,
        "show_in_menu" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => false,
        "rewrite" => array( "slug" => "designer_collections", "with_front" => true ),
        "query_var" => true,
        "menu_icon" => "dashicons-portfolio",
        "supports" => array( "title", "editor", "thumbnail" ),
        "taxonomies" => array( "collection_types" ),
    );

    register_post_type( "designer_collections", $args );
}

add_action( 'init', 'cptui_register_my_cpts_designer_collections' );
danimalweb commented 7 years ago

Here are a few images in the WP-Admin and Database.

http://imgur.com/a/scrJb

Tusko commented 7 years ago

@danimalweb I've created the new CPT (with your code), everything is ok https://cl.ly/k0fX

I don't know what to say :)

danimalweb commented 7 years ago

Ok thanks, I'll try and do a reduced test case at my end. Cheers.

danimalweb commented 7 years ago

Found my issue, I was assigning the Options to a manually created (via code) Options Page for that CPT and not using the one automatically created by the plugin.

Tusko commented 7 years ago

Got it! Thank you for issue :)