This topic has 6 replies, 2 voices, and was last updated 9 years by akal.

  • Author
  • #54829
     akal
    Participant

    Hi,

    I continue to move forward on my website project with the KLEO template and it’s a pleasure to work on it.
    Like I’ve asked to other theme editors (gt3, goodlayer) which were kind enought to develop it, I need a field in the portfolio editor that allow to change the url of the portfolio to a specific link.
    Maybe this function already exists and I have missed it ? If not, can you please provide a short piece of code that I would be able to integrate in the KLEO child ? That would be really kind 😀

    Best Regards

    Akal

    Attachments:
    You must be logged in to view attached files.
    #55184
     Andrei
    Moderator

    Can you please post a bigger screenshot with the place where you want this to be implemented because I can’t manage to figure where this field should be located.

    Looking forward.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #55261
     akal
    Participant

    Hi,

    thank for your reply. This should be implemented in “Edit Portfolio item” (view screenshot).

    Below it is what I’ve implemented for another WP theme.
    I’m not good enought to change this code to fit with KLEO but if you are ok with that, maybe you could do the adaptation for me ?

    <u>Admin Portfolio Edition : (portfolio-masonry.php I guess ?)</u>
    “Portfolio Custom Link” => array(
    ‘title’=> __(‘Portfolio Link’, ‘xxx-theme-name’),
    ‘name’=>’portfolio-custom-link’,
    ‘type’=>’inputtext’,
    ‘description’=>’This will change the url of the portfolio to a specified link’
    ),

    <u>Portfolio item : (single-portfolio.php I guess ?)</u>
    $custom_permalink = get_post_meta(get_the_ID(), ‘portfolio-custom-link’, true);
    if(!empty($custom_permalink)){
    echo ‘‘ . get_the_title() . ‘‘;
    }else{
    echo ‘‘ . get_the_title() . ‘‘;
    }

    Hope It’s clear enought ^^
    Cheers

    Akal

    Attachments:
    You must be logged in to view attached files.
    #55265
     Andrei
    Moderator

    Why would you need to add a separate field and build custom functionality for this, when you can edit the permalink by default directly from wordpress, by pressing the edit button below the title field.

    http://seventhqueen.com/public-files/andrei_2015-04-20_16-50-57.png

    Let me know if there is any difference from this feature and what you’re trying to achieve.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #55266
     akal
    Participant

    This is not about permalink, this is about associate a custom link (like a wordpress Page) to the portfolio
    Example : http://dev16.digitalis-web.fr/
    if you clic on one of the first 8 items, you naturaly go to the portfolio related page.
    Example : if you clic on “Fitness Musculation Paris…” you’ll go to http://dev16.digitalis-web.fr/portfolio/fitness/
    What I’m looking for is to be able to send you to another page or post or external link, what ever. For my example I want to send people here => http://dev16.digitalis-web.fr/activites-sport-et-loisirs/fitness-musculation/
    I could do that with the 301 redirection function of Yoast SEO Plugin, but it’s a redirection and I’m looking for a native link.

    #55271
     Andrei
    Moderator

    I see, then please try to use the following functionm which should be added to your active theme, in the functions.php file, and it should be used in combination with the redirect field provided by the Yoast Seo plugin. It should change your link directly from the listing without any template modifications. Please note that links will be changed in the whole site.

    COPY CODE
    
    function kleo_portfolio_permalink_using_yoast_redirect( $url, $post, $leavename ) {
        if ( $post->post_type == 'portfolio' ) {
            $yoast_redirect = get_post_meta($post->ID, '_yoast_wpseo_redirect', true);
            if($yoast_redirect){
                return $yoast_redirect;
            }
        }
        return $url;
    }
    add_filter( 'post_type_link', 'kleo_portfolio_permalink_using_yoast_redirect', 10, 3 );
    

    Let me know if it worked.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #55274
     akal
    Participant

    Thank for that, works perfectly !
    Cheers 🙂
    Akal

Viewing 7 posts - 1 through 7 (of 7 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?