Community Forums › Forums › Archived Forums › General Discussion › URL Appendage Problem
- This topic has 8 replies, 2 voices, and was last updated 8 years, 4 months ago by Christoph.
-
AuthorPosts
-
July 27, 2016 at 3:34 pm #190331eluviisMember
Hi,
I'm using the code from minimum to create a portfolio post-type for another Studiopress theme. I've done this before because I really like this little feature. Here's the problem I'm having though. On this particular site, the blog has "blog" prepended to the postname URL. I never do this, but this site has that. Well, I created the CPT (code below) and my problem is that the CPT archive presents itself as /blog/portfolio - I want it to be just /portfolio/
Any idea what's going on?
`/** Custom - Create portfolio custom post type */
add_action( 'init', 'minimum_portfolio_post_type' );
function minimum_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'minimum' ),
'singular_name' => __( 'Portfolio', 'minimum' ),
),
'exclude_from_search' => false,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-admin-page',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
)
);
}July 27, 2016 at 3:45 pm #190332eluviisMemberBasically, I don't want "/blog/" prepended to the post name on my portfolio CPT like it is on the blog. How do I edit the code above to avoid that?
July 27, 2016 at 4:39 pm #190337ChristophMemberHi,
you can try changing the rewrite part to:
'rewrite' => array('with_front' => false, 'slug' => 'portfolio' ),
July 27, 2016 at 5:25 pm #190342eluviisMemberHi, thanks, but that doesn't really help. See, all that with_front' => false does is that the posts themselves do not get the "portfolio" slug prepended. But my problem is that I'm getting the "blog" slug prepended before "portfolio" because it's in the permalink settings to add that to the blog. But I don't want that to affect my custom post types such as this one.
July 27, 2016 at 5:29 pm #190343eluviisMemberEDIT: Nevermind. That seems to have done the trick. It's working now.
Quick question. That code that I posted above is based off the original Minimum theme, ie, not HTML5. The new Minimum Pro them (HTML5) uses templates for the portfolio custom post type. Am I asking for trouble here, or is the code above perfectly legitimate?
July 27, 2016 at 6:01 pm #190345ChristophMemberI´m glad it´s working.
No, this code is independent from the HTML version that is used to display the content. You should have no problems.
Executive Pro is the "go to HTML5 theme" to borrow the code to register a portfolio CPT but you could also take the code from the new Genesis Portfolio Pro plugin (https://wordpress.org/plugins/genesis-portfolio-pro/)
July 27, 2016 at 6:27 pm #190348eluviisMember^^^ Thanks. That plugin might be very useful. I got the CPT working great now thanks to you. However, the old CSS code I used to use doesn't play nice with the theme I'm using now. Maybe this plugin will give me CSS code I can use. Apart from that, I can't have the portfolio named "portfolio" - needs to be gallery, so I've changed all the names with search and replace.
July 28, 2016 at 11:24 am #190387eluviisMember@Christoph - That portfolio plugin is actually really good. I like how it works and I like how it includes the CSS I need to make it look more or less how I want. Hard-coding it in the way I usually do it won't give me this kind of depth as I usually do it much more simpler.
One question though. You think there is way I can change "portfolio" to "gallery" in the plugin without hacking the plugin? I don't want it to revert back to portfolio during the next update. Otherwise, really good.
July 28, 2016 at 11:50 pm #190420ChristophMemberThere is no interface to change the CPT name.
You could upload a renamed copy of the plugin in which you change post-types-and-taxonomies.php
to use gallery instead of portfolio.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.