Tagged: ,

Viewing 24 posts - 1 through 24 (of 24 total)
  • Author
    Posts
  • #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/product

    If 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, 11 months ago by educode.
    #735882

    Hey 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, 11 months ago by Yigit.
    #735921

    Hi 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!

    #735927

    Hey!

    There was a typo in the code i fixed it. Please try copying it once again

    Best regards,
    Yigit

    #735971

    Thanks 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

    #735975

    Hey!

    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,
    Yigit

    #735984

    Changed 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

    #735991

    Hi!

    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!
    Yigit

    #736032

    Dear 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!

    #736046

    Hi!

    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,
    Yigit

    #736062

    user sulcorte pass Pok1Pok1

    same as wp and ftp

    #736068

    Hi!

    I am copy pasting but it is still not working unfortunately.

    Cheers!
    Yigit

    #736075

    Try port 21

    #736194

    Hey!

    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,
    Ismael

    #822708

    Hey 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?
    Thanx

    #823516

    Hi,

    After adding the code, please go to
    Settings -> Permalinks

    and from there select custom and save.

    Let us know if that issue will solve the problem for u.

    Best regards,
    Basilis

    #843244

    I tried to use this code in my site and it made all of the pages (unless the front page) go 404.

    #844649

    Hi,

    Did you flush permalink after adding the code? Please go to the Settings > Permalink panel after adding the modification.

    Best regards,
    Ismael

    #844702

    What 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…

    #845201

    Hi,

    Please don’t remove the portfolio base slug option. Just go to the Settings > Permalink settings then click “Save Changes” once.

    Best regards,
    Ismael

    #845370

    Did just what you did – It made all of the pages (instead of the front page) go 404.

    #845673

    Hi,

    Alright. Please create a new thread with the site url and the login credentials. We’ll check it there.

    Best regards,
    Ismael

    #862088

    Hi. 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 – Raphe

    #862339

    Hi,

    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

Viewing 24 posts - 1 through 24 (of 24 total)
  • The topic ‘Portfolio categories into URL Permalink’ is closed to new replies.