Git Product home page Git Product logo

wp-custom-post-type-class's Introduction

wp-custom-post-type-class's People

Contributors

jjgrainger avatar kalenjohnson avatar matthewsoares avatar vinkla avatar willthemoor avatar zentheme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-custom-post-type-class's Issues

Custom labels

I don't believe this is currently possible. It'd be useful to be able to override the default post type labels. I often like to set a custom menu_name for example.

Supports array has too many defaults

I think the 'supports' default array needs to be empty. I want a CPT with only a title, but because the default array contains 'title', 'editor' and 'thumbnail', these still get included with the merge. I may be doing something wrong, but was curious if anyone else has seen this.

I think line 508 should be:

'supports' => array(),

Am I missing something?

v1.3.2 error

I've just upgraded to v1.3.2 and am seeing the following error.

Warning: Invalid argument supplied for foreach() in /var/www/project/vendor/jjgrainger/wp-custom-post-type-class/src/CPT.php on line 568

Needs a has_archive flag

I frequently disable the CPT archive and use a custom page template instead - basically any time the classic blog list format doesn't apply.

Will try to hack it in real quick but if I submit a pull request, it may not be how you'd do it within your structure.

Won't register on add_action('init')

When I try to use this class in a custom plugin, it won't register on add_action('init'). I need to use add_action('plugins_loaded') to get it to register, but that doesn't feel ok.

If I replace $book->CPT(...) with wordpress own register_post_type, it works on add_action('init').

Any ideas?

Changing the bulk actions

I would say your class is fantastic. I am very satisfied using CPT Class. I would like to know if it might be possible to implement some methods to change the navigation of bulk-action-selector-top, or the actions of the date filter selector. Example: Show ACF datepicker in the dropdown date filter.

Adding post_row_actions

Hello:

Thank you for the great work on this class. Makes setup and config so much easier for us. I was wondering if there's a way to add post_row_actions to a custom column? I have a CPT for 'people' that is not using the default post title, and instead I've created a column that displays last_name, first_name and I'd like to have row actions (pictured) available on hover if possible.

Thanks for any help you can offer.

screen shot 2016-11-01 at 1 38 24 pm

Call to undefined function array

This showed up in a deploy to a wordpress site, but I have deployed same to other servers without this error...

Fatal error: Call to undefined function array_replace_recursive() in /home/content/j/o/s/sitenamehere/html/wp-content/themes/themename/inc/post-types/CPT.php on line 512

post type to enable in wp-api

I just read that wp-api 2 does not supports from default custom type. This one needs to be enabled by passed $args like 'show_in_rest' => true,. How would I do that?

cut 'post'

Hello
I was wondering whether it is possible to set the menu_position of the cpt 'post'?

Custom taxonomies not registering?

I may be missing something here.. Wordpress is something I only touch a couple times a year, so I'm very rusty.

I have an $options array defined, then:

$staff = new CPT('Staff Member', $options);
$staff->register_taxonomy('departments');

That should work, correct? Or is it more involved than this? It's not adding the "Staff Members -> Departments" menu option in the Wordpress ui at all. I can add the existing "Categories" taxonomy to post types, but registering new ones doesn't seem to do anything.

No error messages or anything, so I get the vibe that I'm overlooking a step. I've also tried calling it via the $options taxonomies array too, but no success there either..

Thanks ahead of time

Adding custom columns removed wordpress edit, quick edit, trash and view links

screen shot 2017-05-02 at 19 42 19

Using code similar to below:

$enquiries->columns(array(
	'cb' => '<input type="checkbox" />',
	'name' => __('Name'),
	'email' => __('Email'),
	'telephone' => __('Telephone')
));

$enquiries->populate_column('name', function($column, $post) {
	echo get_field('name');
});

$enquiries->populate_column('email', function($column, $post) {
	echo get_field('email');
});

$enquiries->populate_column('telephone', function($column, $post) {
	echo get_field('telephone'); 
});

Default columns breaks all columns.

From version 1.3 to 1.3.1 the added default columns seems to break all columns registered by other plugins and if no custom columns are registered as well.

In order to get around this I currently set the first defaults columns array to $default and then did a $columns = array_replace_recursive( $defaults, $columns ); Not sure that's to final and best way, but it currently takes care of the issue.

How do I add field price

Thank you your Class. It's very well done

I want to add some fields, example price

How do I add field price ?

Thanks & Regards

Issues with Menu Icons

Hi mate

Very cool class, but the menu icons aren't working for me. My IDE isn't actually recognising $this->menu_icon['hover'] as available from within the set_post_icon() method.

I'm setting up the CPT like so;

$teams = new CPT(array(
                        'post_type_name' => 'grdl_team',
                        'singular'       => 'Team',
                        'plural'         => 'Teams',
                        'slug'           => 'teams'
                  ),
                  array(
                        'supports' => array('title', 'editor'),
                        'hierarchical' => false,
                        'has_archive' => true
                  ));
$teams->menu_icon('dashicons-book-alt');

The logo doesn't change in the admin and I get the following errors;

[06-Jan-2014 23:57:31 UTC] PHP Notice:  Undefined property: CPT::$menu_icon in /xxx/wp-content/themes/pds-master/library/vendor/CPT.php on line 1148
[06-Jan-2014 23:57:31 UTC] PHP Notice:  Undefined property: CPT::$menu_icon in /xxx/wp-content/themes/pds-master/library/vendor/CPT.php on line 1153
[06-Jan-2014 23:57:31 UTC] PHP Notice:  Undefined property: CPT::$menu_icon in /xxx/wp-content/themes/pds-master/library/vendor/CPT.php on line 1157

Has Archive

I cant seem to find a way to register these with Archives. Im not seeing it anywhere in the source code either.

This can only register post types as "pages" without archives it seems.

Custom taxonomy not registering

I can't seem to be able to register a custom tax to my CPT. Here my code in the simplest form possible, but yet it won't show up in the admin screen.

There was a similar issue about a year ago, but I tripled checked my code and all seems to be in order.
https://github.com/jjgrainger/wp-custom-post-type-class/issues/25

What am I not seeing?

$movies = new CPT( array(
    'post_type_name'    => 'movie',
    'singular'          => 'Movie',
    'plural'            => 'Movies',
    'slug'              => 'movies',
));

$movies->register_taxonomy('genre');
$movies->register_post_type();
$movies->flush();

Enabling the Packagist service hook.

It seams that this repository is not automatically synced into GitHub. Maybe you could add the GitHub Service Hook in the repository settings? Then you wont need to visit packagist for each new release.

GitHub Service Hook
Enabling the Packagist service hook ensures that your package will always be updated instantly when you push to GitHub.

The API token is located on your profile page.

Add menu_position

Tried to add the CPT higher on the menu.

function menu_position( $position = 5) {
    $this->options["menu_position"] = $position;
}

This works.

Custom capabilities in CPT

It's nice class. However, it could be even better by adding custom capabilities option. Are you planning or give some sort of idea to add it?

Setting labels

hello
I was wondering whether it is possible to set some labels as well so I could have something like "All Books"?

Thanks

Using CPT

Hello
Could you please tell me how I could set up the following code using your class:

register_post_type( 'ta_case',
array(
'labels' => array(
'name' => __( 'Cases', 'ta' ),
'singular_name' => __( 'Case', 'ta' ),
'add_new_item' => __( 'Add new case', 'ta' ),
),
'has_archive' => true,
'hierarchical' => false,
'menu_icon' => 'dashicons-book-alt',
'menu_position' => 50,
'public' => true,
'rewrite' => array( 'slug' => 'case', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' )
)
);

Thanks

Options array can also be boolean false

I used this class to create a CPT yesterday (great job on this class BTW) and using it with the Advanced Custom Fields plugin is awesome. I wanted to create a CPT that used none of the WP default options...it's possible (since WP 3.5) to do so by passing a boolean false for the 'supports' option. I added a small modification to the code to allow this on line 270:

if ($options === false) return false;

Thought you might consider adding this to the class.

Issue with multiple post-types with same taxonomy :: Two post-types can't have same taxonomy

i created two objects $book and $person, and an taxonomy author_type.

$books->register_taxonomy(array(
    'taxonomy_name' => 'author_type',
));
$person->register_taxonomy(array(
    'taxonomy_name' => 'author_type',
));

but the taxonomy is available for only the last declared object $person but $books did't get the auther_type taxonomy...

I don't know may be i am doing something wrong..

PHP Warning line 865

Warning: Invalid argument supplied for foreach() in /jjgrainger/wp-custom-post-type-class/src/CPT.php on line 865.

I get this warning because it tries to pass a NULL value to a foreach loop. I fixed by typecasting it to an array.

foreach((array) $filters as $tax_slug) {

adding a way to set column width

Was wondering whether there's a way to add a column width - would be nice to have this feature for e.g. true/false columns so they would not take that much space.

How to translate post type name

i don't know if i'm doing something wrong but i'm not able to translate the name of the post type/taxonomy... not the 'Add New' label but the singular and plural names of the post type/taxonomy (ie: my CPT singular name is "Brands" and i want to translate "Brands").

this is the way i'm registering the post type

// Register Brand custom post type
$brand = new CPT(
    // Names
    array(
        'post_type_name'    => 'brand',
        'singular'          => 'Brand',
        'plural'            => 'Brands',
        'slug'              => 'brands'
    ),
    // Options
    array(
        'has_archive'           => true,
        'supports'              => array('title', 'editor', 'author', 'thumbnail', 'revisions'),
        'exclude_from_search'   => true,
        'map_meta_cap'          => true,
        'capabilities'          => array(
            'edit_post'             => 'edit_brand',
            'edit_posts'            => 'edit_brands',
            'edit_others_posts'     => 'edit_other_brands',
            'publish_posts'         => 'publish_brands',
            'read_post'             => 'read_brand',
            'read_private_posts'    => 'read_private_brands',
            'delete_post'           => 'delete_brand'
        )
    )                 
);
// Icon
$brand->menu_icon('dashicons-star-filled');
// Translation
$brand->set_textdomain('my-text-domain');

i also tried using WordPress translation functions in the names section like so:

    array(
        'post_type_name'    => 'brand',
        'singular'          => __('Brand'),
        'plural'            => __('Brands'),
        'slug'              => 'brands'
    ),

and with adding a text domain name

    array(
        'post_type_name'    => 'brand',
        'singular'          => __('Brand', 'my-text-domain'),
        'plural'            => __('Brands', 'my-text-domain'),
        'slug'              => 'brands'
    ),

hope you can help.
thnx.

Custom Post Types: Sharing Multiple Custom Taxonomies

Hi! I have an issue where I registered a custom post type with two custom taxonomies which works, but when I register a second custom post type that uses those same taxonomies, they only appear under the list view of the second custom post type but not on the actual menu nor in the edit page. Am I missing something?

This is the custom post type with the two original taxonomies:
screen shot 2015-05-19 at 8 42 20 pm

And here is the second custom post type with the taxonomies only showing up in the admin list view:
screen shot 2015-05-19 at 8 42 55 pm
screen shot 2015-05-19 at 8 43 11 pm
screen shot 2015-05-19 at 8 42 44 pm

My code:

//Litigation Graphics
$litigation = new CPT(
[
    'post_type_name' => 'litigation_graphics',
    'singular'       => 'Litigation Graphic',
    'plural'         => 'Litigation Graphics',
    'slug'           => 'litigation-graphics'
],[
    'supports'       => ['title', 'thumbnail']
]);

$litigation->register_taxonomy(
[
    'taxonomy_name'  => 'media_type',
    'singular'       => 'Media Type',
    'plural'         => 'Media Types',
    'slug'           => 'media-type'
],[
    'hierarchical'   => true
]);

$litigation->register_taxonomy(
[
    'taxonomy_name'  => 'case_type',
    'singular'       => 'Case Type',
    'plural'         => 'Case Types',
    'slug'           => 'case-type'
],[
    'hierarchical'   => true
]);

//Cases
$cases = new CPT(
[
    'post_type_name' => 'cases',
    'singular'       => 'Case',
    'plural'         => 'Cases',
    'slug'           => 'experience'
],[ 
    'supports'       => ['title', 'thumbnail', 'editor']
]);

$cases->register_taxonomy(
[
    'taxonomy_name'  => 'industry',
    'singular'       => 'Industry',
    'plural'         => 'Industries',
    'slug'           => 'industry'
],[
    'hierarchical'   => true
]);

$cases->register_taxonomy(['taxonomy_name'  => 'media_type']);
$cases->register_taxonomy(['taxonomy_name'  => 'case_type']);

sortable doesn't work

The sortable doesn't seem to work for me. When I click any of the sorting columns (price or rating) it just returns blank list.
screen shot 2014-01-21 at 5 35 26 pm
screen shot 2014-01-21 at 5 35 43 pm
screen shot 2014-01-21 at 5 36 53 pm

Did I miss something?

Register taxonomies first?

Thanks for this class, very useful!

One note, in order to ensure taxonomy permalinks always work, it's useful to switch lines 168 and 171, so that the taxonomies are registered first. Bizarre but true, see this post: http://clarknikdelpowell.com/blog/the-right-way-to-do-wordpress-custom-taxonomy-rewrites/

In the current configuration, taxonomy slugs that include a path ("books/genre") instead of just a simple slug ("genre") get created correctly, but result in 404's when you surf to them. Swap so taxonomies are registered first, and they work.

Issuse: Atribute panel no showing parent select

First of all thx for the code :)

When the custom post is created i can´t get the hierarchy to work properly.

image

The 'Parent' select does not show up ( And yes, i do have more than one post of the same post-type )

image

Thanks for all.

Category

How do I add category for custom post type ? It's similar Posts/Category

Thanks & Regards

Could not translate "Add New" label

Is it a typo that you wrote:

'add_new' => _('Add New'),

I use WPML and could not translate this label. If I change it manually to

'add_new' => __('Add New'),

I can translate the label.

Error when defining taxonomies

Hi,

First off all, thanks for the code. Registering post types is a breeze but when registering taxonomies, it returns this error:

Fatal error: Call to a member function add_rewrite_tag() on a non-object in .../wp-includes/rewrite.php on line 51

I am using WordPress 3.7.1 by the way.

PHP Warning in add_admin_columns

I'm getting the following warnings:

PHP Warning: in_array() expects parameter 2 to be array, null given in [theme]/inc/CPT.php on line 591
PHP Warning: in_array() expects parameter 2 to be array, null given in [theme]/inc/CPT.php on line 593

I'm just using this in a pretty basic way, not adding any taxonomies to my CPT. Should this check if there are any taxonomies to work with earlier? (currently does this on :611)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.