1457 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
+6 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
  • Has been part of the Envato Community for over 3 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+3 more
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.

2468 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
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 :)

1457 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
+6 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?

2468 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
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 :)

1457 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
+6 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Located in Canada
  • Has collected more than 1000 items on Envato Market
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.

1457 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
+6 more
fuelthemes says

Found it!

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

1457 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Has been part of the Envato Community for over 5 years
  • Has sold $250,000+ on Envato Market
+6 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!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by