Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #659999

    I’m looking for the single portfolio template. I need to change it to add a custom field. What file must I modify?

    #660102

    Hey alnalu!

    If you are using ALB, that is not possible to be done.
    Can you please give us some more informations what you need to do so we can help you?
    based on the area, there might be a hook which can be used.

    Best regards,
    Basilis

    #660235

    Sure,

    I need to have two diferent titles for any porfolio item. One title is show on portfolio gallery. The other one is show on portfolio item.
    I’ve done this in the pages, using a template. But I dont know what file must modify to add a custom field on a portfolio item.

    #661222

    Hi,

    Would using shortcodes help you? Also, can you please post a screenshot and show the changes you would like to make so we can understand better? :)
    You can upload your screenshots on imgur.com or Dropbox public folder and post the links here

    Best regards,
    Yigit

    #661278

    Here

    #661287

    Hi!

    Please try adding following code to Functions.php file in Appearance > Editor

    add_filter('avf_title_args', 'fix_single_portfolio_title', 10, 2);
    function fix_single_portfolio_title($args,$id)
    {
        if (is_singular( 'portfolio' ))
        {
            $args['title'] = get_custom_title();
            $args['link'] = get_permalink($id);
            $args['heading'] = 'h1';
        }
    
        return $args;
    }

    Cheers!
    Yigit

    #661442

    It doesn’t works. This causes a 500 error appears in the frontend.
    The custom fields options of portfolio items are not visibles.

    #661543

    Hi!

    Do you mind posting temporary admin logins and FTP logins to your development server so we can look into it?

    Best regards,
    Yigit

    #664561

    login data

    #665594

    Hi,

    What is the name of the custom field? Portfolio items do not support custom fields by default so you have to add this in the functions.php file to enable custom fields on portfolio items:

    //enable custom fields for portfolio items 
    add_filter( 'avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 1 );
    function avf_portfolio_cpt_args_mod( $args ) {
    	$args['supports'][] = 'custom-fields';
    	return $args;
    }

    Change the value of the meta key (customfieldname) here:

    add_filter('avf_title_args', 'fix_single_portfolio_title', 10, 2);
    function fix_single_portfolio_title($args,$id)
    {
    	$title = get_post_meta($id, 'customfieldname', true);
    
        if (is_singular( 'portfolio' ))
        {
            $args['title'] = $title;
        }
    
        return $args;
    }
    

    Best regards,
    Ismael

    #665637

    Thx Ismael
    It works ok

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Template file for single portfolio’ is closed to new replies.