Tagged: portfolio navigation, portfolio permalinks
-
AuthorPosts
-
February 18, 2016 at 1:10 am #585036
Hey at all,
I’ve read much about permalinks of portfolio-items, but I’m not quite sure, if there however could be a solution for my wishes:
The permalink of posts can be adapted e.g. to /%category%/%postname%/ .
I know, that I can change the base slug for portfolio-items. So far, so good. But is there a way to build the permalink of portfolio-items in a similar way to that of posts, something like /%portfolio-category%/%portfolio-item%/, and if yes, how do I reach that?If this is not possible without creating an additional custom post type like the type portfolio, is there a way to adapt the portfolio navigation to pages?
Regards,
HellaFebruary 19, 2016 at 4:50 am #585824Hi Hella,
I’m not sure if what you are looking to do is possible or not, maybe you can ask the question in a general WordPress forum instead? You are much more likely to get help there. If you want you could check this plugin out: https://wordpress.org/plugins/custom-permalinks/
Thanks,
RikardFebruary 19, 2016 at 12:12 pm #585970Hey Rikard,
that idea get’s me very close to what I wanted, thank you very much for pointing me in that direction. A plugin which seems to work more stable with the current WordPress version is https://wordpress.org/plugins/custom-post-type-permalinks/.
Unfortunately the base of the custom post type portfolio obviously cannot be removed, which is a petty, because the URL doesn’t match the structure of my menu. I suppose, I would have the section in the php files, where the post type and its permalink structure are defined.
Regards,
HellaFebruary 22, 2016 at 3:32 pm #587199Hi!
does it work for you when activating a default WordPress theme?
Best regards,
AndyFebruary 22, 2016 at 5:16 pm #587294Hey Andy,
perhaps I do not understand completely, what you want me to show – but no, if I activate a default WordPress theme, I naturally have no portfolio post type items at all.
It’s okay, I’ll try to sort out another structure which fits to the possibilities of the theme.Regards,
HellaFebruary 24, 2016 at 5:26 am #588124Hi!
It’s possible to remove the default portfolio slug. Add the following code functions.php file then flush the Settings > Permalinks options afterwards:
add_filter( 'post_type_link', 'ava_remove_custom_slug', 10, 3 ); function ava_remove_custom_slug( $post_link, $post, $leavename ) { if ( 'portfolio' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); return $post_link; }
If you need to append the portfolio category, you can use the following plugin but you can only attach one category in the url:
https://wordpress.org/plugins/custom-post-type-permalinks/Cheers!
IsmaelFebruary 24, 2016 at 4:35 pm #588474Hey Ismael,
that seemed to be exactly what I was looking for!
Unfortunately it doesn’t work, items are not found, although there’s no conflict with identical slugs. (Yes, I’ve updated the permalink options in the WordPress settings.). I’ve put the code snippet into my child themes function.php, that should be okay, is it right?Appending portfolio categories works quite good with the mentioned plugin. If I do not remove the base slug with your code snippet, I even can add nested categories and the permalinks work well.
At the moment, your code snippet is active and the permalinks are flushed.
Regards,
HellaFebruary 27, 2016 at 6:30 am #590158Hey!
We modified the code above. Please use it then flush the permalink a few times. A link to the actual portfolio page will help.
Cheers!
IsmaelMarch 1, 2016 at 11:43 am #591463Hey Ismael,
thank you for your support, but unfortunately it doesn’t work. The base slug is removed from the URL, but the portfolio items cannot be found.I’ve flushed the permalinks and reloaded the site a couple of times.
Regards,
HellaMarch 2, 2016 at 7:35 am #591920Hi!
What happens if you deactivate the plugin? https://wordpress.org/plugins/custom-post-type-permalinks/
Don’t forget to flush the permalinks after deactivation.
Best regards,
IsmaelMarch 2, 2016 at 6:41 pm #592257Hey Ismael,
nothing changes…
Regards,
HellaMarch 3, 2016 at 11:28 am #592561Hi!
Alright. Please post the login details here. We would like to test it. While you’re waiting, please try the solution here: https://kriesi.at/support/topic/portfolio-category-in-url/
Best regards,
IsmaelMarch 3, 2016 at 12:51 pm #592588Hey Ismael,
please find the login data in the private content.
I’ll have a look at the linked topic, thanks!Regards,
HellaMarch 5, 2016 at 1:47 pm #593720Hey!
Removing the default slug “portfolio” is working but when adding the portfolio categories, the item redirects to a 404 page.
http://hella-stroh.de/wp/portfolio-test-mit-neuem-permalink/
Please post the FTP details here so that we can test the site thoroughly.
Best regards,
IsmaelMarch 6, 2016 at 1:20 pm #593907Hey Ismael,
that’s also my observation. Please finde the ftp login data in private content.
Regards,
HellaMarch 9, 2016 at 11:21 am #595464Hi!
This is now working but you can only add one category in the url. Example here: http://hella-stroh.de/wp/galerietest-als-portfolio-item/portfolio-test-mit-neuem-permalink/
You can find the code in the functions.php file.
add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 10); function avf_portfolio_cpt_args_mod($args) { $args['rewrite']['slug'] = '%portfolio_entries%'; $args['rewrite']['with_front'] = false; return $args; } add_filter( 'post_type_link', 'ava_remove_custom_slug', 9999, 3 ); function ava_remove_custom_slug( $post_link, $post, $leavename ) { if ( 'portfolio' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); return $post_link; } add_filter('post_link', 'portfolio_permalink', 1, 5); add_filter('post_type_link', 'portfolio_permalink', 1, 5); function portfolio_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, '%portfolio_entries%') === FALSE) return $permalink; $post = get_post($post_id); if (!$post) return $permalink; $terms = wp_get_object_terms($post->ID, 'portfolio_entries'); if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug; else $taxonomy_slug = 'no-portfolio'; return str_replace('%portfolio_entries%', $taxonomy_slug, $permalink); }
Best regards,
IsmaelMarch 9, 2016 at 12:04 pm #595491Hey Ismael,
thanks a lot for the time invested, I appreciate this much!
But isn’t the result the same, as simply renaming the base slug of the portfolio-items in the permalink structure of the (child) theme itself?Where did you add the code, in the themes function.php or in the function.php of the child theme?
Regards,
HellaMarch 10, 2016 at 9:36 am #596167Hey!
If you’re planning to have only one category then yes, it will be same. Just add the name or slug of the category in the Portfolio Items Base field then you’re all done. What we did above is to remove the default “portfolio” slug then prepend the name of the first category. I deactivated the wp permastruct plugin by the way.
Cheers!
IsmaelMarch 10, 2016 at 10:02 am #596183Hey Ismael,
now I’ve got it – thanks a lot, that fits very well to what I wanted! :)
Just for my understanding: Will the changes remain when the theme files are updated to a new version?Regards,
HellaMarch 10, 2016 at 7:39 pm #596530I apologize in advance if i’m in wrong place.
I’m newbie! :-) … in my site i don’t need to have Porfolio page, but i’d like to use Masonry and Portfolio grid. the problem is that i’d like to use Masonry and portfolio grid to show some staff that it’s linked to a page of my site and it’s not possible for me, second thing it’s better if i put some links because it’s really difficult explain my self by words..
this is my home page under costruction http://studiopsicologoverona.it , now i would like to use Masonry to put staff there is in this page http://studiopsicologoverona.it/problematiche/ and I would like that someone cliks on an image he was redirect to this other page http://studiopsicologoverona.it/problematiche/ansia-attacchi-di-panico/ or to this other http://studiopsicologoverona.it/problematiche/depressione-disturbi-dellumore/ ect… but i’m not able to do this …. is there a solution ? can someone help me?
thanks very mach, it’s a great theme i’d like to use every opportunity it gives to me.
March 11, 2016 at 2:16 am #596647Hey Ismael,
sorry for inconvenience, but could you please revert the changes you’ve made?
Now after you’ve changed the code, my regular blog post entries are not found any longer:
http://hella-stroh.de/wp/dies-und-das/kabelmanagement/As it seems to be not that simple I hoped it would be, I’ll return to the standard behaviour.
Regards,
HellaMarch 11, 2016 at 10:02 am #596790i would be grateful if i could get an aswer to my question please
March 14, 2016 at 7:40 am #597582Hey!
@giorgiosilvia: Please create a new thread for your inquiry. Thank you.@come_pagila: Remove the code in the functions.php file then reset the Permalink settings.
Cheers!
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.