-
AuthorPosts
-
January 16, 2017 at 11:51 pm #734394
I’m trying to apply the real portfolio categories into the URL (with real content from the database).
Example: http:domain.com/real portfolio category/productIf I use the same word as in /wp-admin/options-permalink.php – will not work correctly because I have different products categories in the same portfolio.
Can you help me?
Thank you!
- This topic was modified 7 years, 10 months ago by educode.
January 19, 2017 at 3:01 pm #735882Hey educode,
Thank you for using Enfold.
This is possible but you can only append the first category of the portfolio item. Please add this code in the functions.php file then go to the Settings > Permalinks panel to flush the permalinks.
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); }
Remove browser cache or hard refresh before checking the portfolio items.
Best regards,
Ismael- This reply was modified 7 years, 10 months ago by Yigit.
January 19, 2017 at 4:06 pm #735921Hi Ismael, appreciate your help. Unfortunately, not solved. After this procedure, there is an error message whe trying to connect the site.
Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/sulcorte/www/wp-includes/functions.php on line 5651
Could you have a look?
Cheers!
January 19, 2017 at 4:11 pm #735927Hey!
There was a typo in the code i fixed it. Please try copying it once again
Best regards,
YigitJanuary 19, 2017 at 5:09 pm #735971Thanks Yigit! Still not working, changed the message thought.
Fatal error: Cannot redeclare ava_remove_custom_slug() (previously declared in /home/sulcorte/www/wp-includes/functions.php:5641) in /home/sulcorte/www/wp-includes/functions.php on line 5666
January 19, 2017 at 5:12 pm #735975Hey!
It seems like you are editing wp-includes/functions.php file. Please do not do that. You need to edit wp-content/themes/enfold/functions.php file
Best regards,
YigitJanuary 19, 2017 at 5:24 pm #735984Changed the suggested file and…
Fatal error: Cannot redeclare ava_remove_custom_slug() (previously declared in /home/sulcorte/www/wp-includes/functions.php:5641) in /home/sulcorte/www/wp-content/themes/enfold/functions.php on line 581
January 19, 2017 at 5:40 pm #735991Hi!
Please go to wp-includes/functions.php and remove ava_remove_custom_slug” function from the file. It should be on 5641st line in the file.
FTP logins are not working for me “Server said: PWD: Permission denied”Cheers!
YigitJanuary 19, 2017 at 7:20 pm #736032Dear Yigit still not working and changing the error message to another lines….
Please help me. My client is overreacting about the URL problem.
Tried the FTP and its Okay now. It was blocked for foreign access.
Thank you in advance!
January 19, 2017 at 7:47 pm #736046Hi!
Now i am getting “The user name or password was not accepted by the server.” error and WP login page cannot be found
Best regards,
YigitJanuary 19, 2017 at 8:12 pm #736062user sulcorte pass Pok1Pok1
same as wp and ftp
January 19, 2017 at 8:22 pm #736068January 19, 2017 at 8:34 pm #736075Try port 21
January 20, 2017 at 5:44 am #736194Hey!
The error means that the function was duplicated. Please revert the files back to their original state or remove all modifications that you’ve done in the previous hours then make sure that you put the snippet in the wp-content > themes > enfold > functions.php file, nowhere else. And please copy the snippet directly from this forum, not from your email.
Best regards,
IsmaelJuly 17, 2017 at 4:00 pm #822708Hey maybe someone can help, please!
When i add the code above the Site works correct with Portfolio Entries but not with normal Pages linked out of the Menu i get a 404 Site not found. What did i do wrong?
ThanxJuly 18, 2017 at 10:16 pm #823516Hi,
After adding the code, please go to
Settings -> Permalinksand from there select custom and save.
Let us know if that issue will solve the problem for u.
Best regards,
BasilisAugust 23, 2017 at 8:05 pm #843244I tried to use this code in my site and it made all of the pages (unless the front page) go 404.
August 28, 2017 at 5:15 am #844649Hi,
Did you flush permalink after adding the code? Please go to the Settings > Permalink panel after adding the modification.
Best regards,
IsmaelAugust 28, 2017 at 7:32 am #844702What do you mean by “flush”?
After I added the code I went to the permalink page, removed the content of the portfolio fields and saved changes. Then everything went 404.Actually, when I trird to add the code without changing anything in the permalink settings page it did work – but only until I added a new blog post and then everything went 404…
August 29, 2017 at 6:26 am #845201Hi,
Please don’t remove the portfolio base slug option. Just go to the Settings > Permalink settings then click “Save Changes” once.
Best regards,
IsmaelAugust 29, 2017 at 3:51 pm #845370Did just what you did – It made all of the pages (instead of the front page) go 404.
August 30, 2017 at 8:30 am #845673Hi,
Alright. Please create a new thread with the site url and the login credentials. We’ll check it there.
Best regards,
IsmaelOctober 9, 2017 at 8:27 pm #862088Hi. I’ve tried using the code and nothing happens. Where exactly in the functions.php file should the code be added? Does it need a // before it? What should my custom permalink be -currently using /%category%/%postname%/
Nothing seems to make any difference.
Regards – RapheOctober 10, 2017 at 8:11 am #862339Hi,
The continuation of the discussion can be found here.
// https://kriesi.at/support/topic/portfolio-url-permalink-to-have-categories/#post-849450
We suggested a plugin.
// https://wordpress.org/plugins/custom-post-type-permalinks/
We’ll close this thread for now. Please create a new thread with the url to the site and the login credentials.
Best regards,
Ismael -
AuthorPosts
- The topic ‘Portfolio categories into URL Permalink’ is closed to new replies.