Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1064671

    Guys,

    I saw this suuport query https://kriesi.at/support/topic/portfolio-page-adding-a-line-of-text-under-the-page-title/. I went to the single.php page but could not see where to add the following code
    $punchline = get_post_meta($post->ID, “punchline”, true);
    if($punchline != “”) { echo “<h3>”.$punchline.”</h3>”; }

    Can you please help

    Pete

    #1065117

    Hey condonpb,

    Here is the code you can put in your funtions.php

    
    function add_portfolio_punchline() {
    	if ( is_single() && 'portfolio' == get_post_type() ) {
    		$punchline = get_post_meta($post->ID, "punchline", true);
    		if($punchline != "") { echo "<h3>".$punchline."</h3>"; }
    	}
    
    }
    add_action('ava_after_main_title', 'add_portfolio_punchline');
    

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1065692

    Victoria,

    I have now added this into functions.php file but in portfolio settings, I can’t see where to add the custom field can you please help.

    Many Thanks

    Pete

    #1066223

    Hi Pete,

    Go to the page and edit it.
    If gutenberg is enabled: In the upper right corner there are 3 dots click on it then select options then check Custom Fields.
    If classic editor is enabled: In the upper right corner, click Screen Options then check Custom Fields.
    You should see the custom fields at the bottom of the page.

    Best regards,
    Nikko

    #1069374

    Nikko,

    Sorry I dont see a screen option called custom fields here please see screenshot from portfolio screen

    http://peter-test2.co.uk/Screenshot.jpg

    Can you please advise

    #1069496

    Hi condonpb,

    I see, try adding this php code in functions.php:

    add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_custom');
    function avf_portfolio_cpt_args_custom($args) {
    	$args['supports'] = array('title','thumbnail','excerpt','editor','comments', 'revisions', 'custom-fields' );
    	return $args;
    }

    Best regards,
    Nikko

    #1070094

    Nikko,

    I have now added code and see now the custom field which I have now enetered in a custom filed called punchline but see nothing. The code I have entered now in the php file is below. I entered in the portfolio custom field “punchline” a price of £1750 and was hoping this would appear on the portfolio page under the title so we would have ……..Jill Barthorpe – Late Apples (TITLE)
    £1750 (PRICE)

    see http://www.peter-test1.co.uk/british-contemporary-art/jill-barthorpe-paintings/ where the is nothing. I have created a login if that helps
    PHP CODE below….

    function add_portfolio_punchline() {
    if ( is_single() && ‘portfolio’ == get_post_type() ) {
    $punchline = get_post_meta($post->ID, “punchline”, true);
    if($punchline != “”) { echo “<h3>”.$punchline.”</h3>”; }
    }

    }
    add_action(‘ava_after_main_title’, ‘add_portfolio_punchline’);
    add_filter(‘avf_portfolio_cpt_args’, ‘avf_portfolio_cpt_args_custom’);
    function avf_portfolio_cpt_args_custom($args) {
    $args[‘supports’] = array(‘title’,’thumbnail’,’excerpt’,’editor’,’comments’, ‘revisions’, ‘custom-fields’ );
    return $args;
    }

    #1071557

    Hi,

    Thanks for the update.

    You have to set the global variable $post.

    // https://codex.wordpress.org/Function_Reference/$post

    The code would look something like this:

    function add_portfolio_punchline() {
    global $post;
    // more code here
    

    Best regards,
    Ismael

    #1072219

    Ismael,

    Thanks for this I have now add the extra pice of code but the price in the custom field comes under the title in the main portfolio image, see http://www.peter-test1.co.uk/art-portfolio-item/jill-barthorpe-late-apples/ which is not what was wanted. What we need is to have the price showing on each of the portfoio thumbnails ONLY see screenshot. http://www.peter-test1.co.uk/price.jpg

    Many Thanks

    Pete

    #1073134

    Hi,

    Thanks for the update.

    You can render the price container under the portfolio item title, but you have to modify the config-templatebuilder > aviashortcodes > portfolio > portfolio.php file directly. Look for this code, which renders the portfolio title, around line 643:

    $output .= "<a href='{$title_link}' title='".esc_attr(strip_tags($title))."'>".$title."</a>";
    

    You can add the price container markup below that line.

    Best regards,
    Ismael

    #1073563

    Ismael,

    Soory I am not very familiar with php. I am not sure what code needs to be added to line 643 can you help please.

    Many thanks

    #1074159

    Hi,

    Thanks for the update.

    Looks for this closing tag around line 650:

    $output .= '</h3></header>';
    

    Replace it with:

    $output .= '</h3>';
    

    And right below that line, add this code to render the custom field.

    $punchline = get_post_meta($the_id, "punchline", true);
    if($punchline != "") $output =. "<h4>".$punchline."</h4>";
    
    $output .= "</header>";
    

    Best regards,
    Ismael

    #1074371

    Thanks for this

    Howver get error when going to website
    Parse error: syntax error, unexpected ‘.’ in /www4/301/www.peter-test1.co.uk/web/wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/portfolio/portfolio.php on line 652

    Current code is see screenshot http://www.peter-test1.co.uk/error.jpg

    #1074660

    Hi,

    There is a syntax error in the string concatenation. Please replace this line:

    if($punchline != "") $output =. "<h4>".$punchline."</h4>";
    

    ..with:

    if($punchline != "") $output .= "<h4>".$punchline."</h4>";
    

    Best regards,
    Ismael

    #1077692

    Ismael.

    Have been away and just got back. Have now applied this and seems to work great!! See http://www.peter-test1.co.uk/artist-test/.

    Just one thing..Is it possible to get the thumbnails sorted by price. so for example when selecting ‘All” on the filter the lowest price is at the left and then increases, then in the current example if you select £500-£1500 we get the thumbnials ordered by prices ie £975, £1,150, £1,200, £1,350

    Many Thanks
    Pete

    #1079795

    Hi Pete,

    Thanks for the update. Glad it’s working.

    Unfortunately, you won’t be able to sort the items by price. It’s possible but that option is not available out of the box, so will require a few modifications. We will not be able to help you with that because it’s beyond the scope of support. Thank you for understanding.

    Best regards,
    Ismael

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.