-
AuthorPosts
-
February 8, 2019 at 5:30 pm #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
February 10, 2019 at 2:46 pm #1065117Hey 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,
VictoriaFebruary 11, 2019 at 9:38 pm #1065692Victoria,
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
February 13, 2019 at 4:58 am #1066223Hi 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,
NikkoFebruary 20, 2019 at 10:50 am #1069374Nikko,
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
February 20, 2019 at 3:34 pm #1069496Hi 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,
NikkoFebruary 21, 2019 at 8:39 pm #1070094Nikko,
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;
}February 26, 2019 at 12:22 am #1071557Hi,
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,
IsmaelFebruary 27, 2019 at 9:38 am #1072219Ismael,
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
March 1, 2019 at 12:55 pm #1073134Hi,
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,
IsmaelMarch 2, 2019 at 8:47 am #1073563Ismael,
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
March 4, 2019 at 6:10 am #1074159Hi,
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,
IsmaelMarch 4, 2019 at 2:24 pm #1074371Thanks 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 652Current code is see screenshot http://www.peter-test1.co.uk/error.jpg
March 5, 2019 at 5:43 am #1074660Hi,
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,
IsmaelMarch 12, 2019 at 7:50 am #1077692Ismael.
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
PeteMarch 18, 2019 at 10:22 am #1079795Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.