jjgrainger / PostTypes

Simple WordPress custom post types.
https://posttypes.jjgrainger.co.uk/
MIT License
373 stars 47 forks source link

Composer #4

Closed mmjaeger closed 7 years ago

mmjaeger commented 7 years ago

Hello was wondering whether this could also be installed without having to install composer?

jjgrainger commented 7 years ago

I believe so, not tried it myself.

But the class has no dependencies itself, Composer is mainly used for its autoloading.

You could try requiring in the classes at the top of your file and see if that works?

mmjaeger commented 7 years ago

Thanks for replying - does the order of including the classes matter?

On Wed, Dec 7, 2016 at 5:59 AM, Joe Grainger notifications@github.com wrote:

I believe so, not tried it myself.

But the class has no dependencies itself, Composer is mainly used for its autoloading.

You could try requiring in the classes https://github.com/jjgrainger/PostTypes/tree/master/src at the top of your file and see if that works?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-265440909, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lIwh7r7nEhYLmxzyj9xuNrzIEkxCks5rFq2cgaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com

jjgrainger commented 7 years ago

@mmjaeger The order of the classes shouldn't matter, no :)

mmjaeger commented 7 years ago

allow me a quick question: how do I properly pass names and options when creating a taxonomy??

On Wed, Dec 7, 2016 at 10:01 AM, Joe Grainger notifications@github.com wrote:

@mmjaeger https://github.com/mmjaeger The order of the classes shouldn't matter, no :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-265505661, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lMEn9BD_m4bfDNK8ue0Yml6zuKPDks5rFuZngaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com

mmjaeger commented 7 years ago

Hello Joe Hope you got a minute - I'm able to create a CPT called "gear" and I'm also able to create a taxonomy called "gear_category" - however, in the list view of all the entries, I'm getting two columns called categories and when adding a category to a post, it doesn't get saved - what am I missing here?

this is what I'm using:

add_action( 'init', 'ct_add_post_types', 0 ); function ct_add_post_types() {

//* Create post type
$names = array(
    'name'      => 'gear',
    'singular'  => 'Gear',
    'plural'    => 'Gear',
    'slug'      => 'gear'
);

$options = array(
    //'taxonomies'          => array( 'gear_category' ),
    'supports'            => array( 'title', 'editor', 'thumbnail',

'revisions', 'genesis-cpt-archives-settings' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 20, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true,

);

$gear = new PostType( $names, $options );

$gear->icon( 'dashicons-camera' );

//* Create taxonomy for post type
$names = array(
    'name'      => 'gear_category',
    'singular'  => 'Category',
    'plural'    => 'Categories',
    'slug'      => 'gear_category'
);

$options = array(
    'public'            => true,
    'hierarchical'      => true,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true
);

$gear->taxonomy( $names, $options );

}

On Fri, Dec 9, 2016 at 10:05 AM, Marco M. Jaeger mmjaeger@gmail.com wrote:

allow me a quick question: how do I properly pass names and options when creating a taxonomy??

On Wed, Dec 7, 2016 at 10:01 AM, Joe Grainger notifications@github.com wrote:

@mmjaeger https://github.com/mmjaeger The order of the classes shouldn't matter, no :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-265505661, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lMEn9BD_m4bfDNK8ue0Yml6zuKPDks5rFuZngaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

mmjaeger commented 7 years ago

this drives me nuts - In the category list view, it actually shows how many posts belong to that category but the categories do not show up in the post list view - if I assign a category in the edit screen, it gets checked until I hit update and then it's unchecked again. Hope you got an idea - thank you in advance for your input. ​

On Fri, Dec 9, 2016 at 2:49 PM, Marco M. Jaeger mmjaeger@gmail.com wrote:

Hello Joe Hope you got a minute - I'm able to create a CPT called "gear" and I'm also able to create a taxonomy called "gear_category" - however, in the list view of all the entries, I'm getting two columns called categories and when adding a category to a post, it doesn't get saved - what am I missing here?

this is what I'm using:

add_action( 'init', 'ct_add_post_types', 0 ); function ct_add_post_types() {

//* Create post type
$names = array(
    'name'      => 'gear',
    'singular'  => 'Gear',
    'plural'    => 'Gear',
    'slug'      => 'gear'
);

$options = array(
    //'taxonomies'          => array( 'gear_category' ),
    'supports'            => array( 'title', 'editor', 'thumbnail',

'revisions', 'genesis-cpt-archives-settings' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 20, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true,

);

$gear = new PostType( $names, $options );

$gear->icon( 'dashicons-camera' );

//* Create taxonomy for post type
$names = array(
    'name'      => 'gear_category',
    'singular'  => 'Category',
    'plural'    => 'Categories',
    'slug'      => 'gear_category'
);

$options = array(
    'public'            => true,
    'hierarchical'      => true,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true
);

$gear->taxonomy( $names, $options );

}

On Fri, Dec 9, 2016 at 10:05 AM, Marco M. Jaeger mmjaeger@gmail.com wrote:

allow me a quick question: how do I properly pass names and options when creating a taxonomy??

On Wed, Dec 7, 2016 at 10:01 AM, Joe Grainger notifications@github.com wrote:

@mmjaeger https://github.com/mmjaeger The order of the classes shouldn't matter, no :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-265505661, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lMEn9BD_m4bfDNK8ue0Yml6zuKPDks5rFuZngaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

mmjaeger commented 7 years ago

Hello Joe Please ignore the last couple email - some plugin I was using caused some issue - however, I tried to make my gear_category column sortable like: $gear->columns()->sortable(['gear_category' => ['gear_category', false ]]);

I does not return the expected result - please see screenshot.

On Fri, Dec 9, 2016 at 4:40 PM, Marco M. Jaeger mmjaeger@gmail.com wrote:

this drives me nuts - In the category list view, it actually shows how many posts belong to that category but the categories do not show up in the post list view - if I assign a category in the edit screen, it gets checked until I hit update and then it's unchecked again. Hope you got an idea - thank you in advance for your input. ​

On Fri, Dec 9, 2016 at 2:49 PM, Marco M. Jaeger mmjaeger@gmail.com wrote:

Hello Joe Hope you got a minute - I'm able to create a CPT called "gear" and I'm also able to create a taxonomy called "gear_category" - however, in the list view of all the entries, I'm getting two columns called categories and when adding a category to a post, it doesn't get saved - what am I missing here?

this is what I'm using:

add_action( 'init', 'ct_add_post_types', 0 ); function ct_add_post_types() {

//* Create post type
$names = array(
    'name'      => 'gear',
    'singular'  => 'Gear',
    'plural'    => 'Gear',
    'slug'      => 'gear'
);

$options = array(
    //'taxonomies'          => array( 'gear_category' ),
    'supports'            => array( 'title', 'editor', 'thumbnail',

'revisions', 'genesis-cpt-archives-settings' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 20, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true,

);

$gear = new PostType( $names, $options );

$gear->icon( 'dashicons-camera' );

//* Create taxonomy for post type
$names = array(
    'name'      => 'gear_category',
    'singular'  => 'Category',
    'plural'    => 'Categories',
    'slug'      => 'gear_category'
);

$options = array(
    'public'            => true,
    'hierarchical'      => true,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true
);

$gear->taxonomy( $names, $options );

}

On Fri, Dec 9, 2016 at 10:05 AM, Marco M. Jaeger mmjaeger@gmail.com wrote:

allow me a quick question: how do I properly pass names and options when creating a taxonomy??

On Wed, Dec 7, 2016 at 10:01 AM, Joe Grainger notifications@github.com wrote:

@mmjaeger https://github.com/mmjaeger The order of the classes shouldn't matter, no :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-265505661, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lMEn9BD_m4bfDNK8ue0Yml6zuKPDks5rFuZngaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

-- Marco M. Jaeger http://net4visions.com

jjgrainger commented 7 years ago

@mmjaeger Sorting taxonomies has come up before with the wp-custom-post-type-class (see this issue) and after researching into it, I don't think this will become a feature.

Reason being is Taxonomies are used for grouping, not sorting posts, and in most cases won't work as expected when you assign multiple terms to a post.

I'd recommend reading this stack overflow, especially this answer. There is a way to do it, but I don't intend on making it a feature of the class.

mmjaeger commented 7 years ago

actually, that makes sense.

thanks

On Tue, Dec 13, 2016 at 2:11 AM, Joe Grainger notifications@github.com wrote:

Sorting taxonomies has come up before with the wp-custom-post-type-class (see this issue https://github.com/jjgrainger/wp-custom-post-type-class/issues/51) and after researching into it, I don't think this will become a feature.

Reason being is Taxonomies are used for grouping, not sorting posts, and in most cases won't work as expected when you assign multiple terms to a post.

I'd recommend reading this stack overflow http://wordpress.stackexchange.com/questions/14306/using-wp-query-is-it-possible-to-orderby-taxonomy/14309, especially this answer http://wordpress.stackexchange.com/questions/14306/using-wp-query-is-it-possible-to-orderby-taxonomy/14309#14309. There is a way to do it, but I don't intend on making it a feature of the class.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jjgrainger/PostTypes/issues/4#issuecomment-266685059, or mute the thread https://github.com/notifications/unsubscribe-auth/ABe4lNL3d9OU5EpyglK6KseaOBhLL6pYks5rHmEvgaJpZM4LDS9B .

-- Marco M. Jaeger http://net4visions.com