1320 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

Hi there,

In my newest theme, I would like the user to select with custom post type categories to show on the page, but could not find a way.

I would really appreciate if you could point me in the right direction.

FYI , I am using the metabox class here: http://www.deluxeblogtips.com/2010/05/howto-meta-box-wordpress.html

254 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
PabloFierro says

You could add in the metabox a select input populated with all the post types your theme has, that will be stored as a meta value for that page, then you can get that value in the page.php file and do a custom query with the post type the user selected.

Good luck.

2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says

$meta_boxes[] = array(
    'id' => 'my-meta-box-2',
    'title' => 'Custom meta box 2',
    'pages' => array('post', 'link'), // custom post type
    'context' => 'normal',
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Categories',
            'id' => $prefix . 'cats',
            'type' => 'taxonomy',                    // taxonomy
            'options' => array(
                'taxonomy' => 'yourtaxonomy',            // taxonomy name
                'type' => 'select',                    // how to show taxonomy? 'select' (default) or 'checkbox_list'
                'args' => array()                    // arguments to query taxonomy, see http://goo.gl/795Vm
            ),
    )
);

Excerpt from here.

You can choose which taxonomy and also have a checkbox list instead of a select :)

1320 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

Thanks digitalimpact,

So if I have a custom post type called “portfolio” and its “portfolio-categories”, do I replace “yourtaxonomy” with “portfolio”?

And do I need any variables in the args array?

2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says

Yup, just replace “yourtaxonomy” with the name of the taxonomy you registered for the Portfolio custom post type.

I think it should work without anything in the args array; that one might be used for advanced stuff like getting terms and so on. args is not mandatory as far as I know, try it and tell us :)

1320 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

Thanks again, I am using the “checkbox_list” type, so the user can select multiple values, but the post meta is not returning an array.

It returns a single value of the first selected checkbox.

701 posts
  • Bought between 1000 and 4999 items
  • Canada
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
chrismccoy says

are you looking to put a dropdown of categories inside the meta box, or just have the categories on the side? where they usally are.

1320 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says

Found it!

WP function has the option to return string or array: http://codex.wordpress.org/Function_Reference/get_post_meta

1320 posts
  • Elite Author
  • Has been a member for 5-6 years
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a Free File of the Month
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
+1 more
fuelthemes says
chrismccoy said
are you looking to put a dropdown of categories inside the meta box, or just have the categories on the side? where they usally are.

This is what I am working on, which will allow the user to have unlimited Portfolio pages: \\

BUT , its not working because the get_categories “exclude” functionality is not working!

by
by
by
by
by
by