Tagged: enfold, real estate
-
AuthorPosts
-
November 8, 2014 at 12:29 am #348003
Hello,
I try to use the Enfold theme for a real estate website. I would like to sort the entries (portfolio) in order of price from highest to lowest. For this I try to use the excerpt because custom fields are not available with portfolio post type. (Unless I’m mistaken?)
My questions are:
– How do I proceed? (add php code to functions.php?, create template page?)
– How to prevent updates replace my configurations? (Child theme?)
– Should I use another method instead?
– Should I rather use an extension of a real estate broker?
– If so, do you know some good real estate plugins which are compatible with the Enfold theme ?
– Do you have any other suggestions for my purposes?(If you are a member of Kriesi team, is it possible to know whether you will eventually add such features in future updates?)
A big thank you in advance.
November 9, 2014 at 7:28 am #348286Hey!
You’d need to use two snippets in functions.php, (child theme would be ideal):
The first one would be to enable custom fields for Portfolio items:
add_filter('avf_portfolio_cpt_args', 'avf_portfolio_add_custom_fields', 1); function avf_portfolio_add_custom_fields($args) { $args['supports'] = array('title','thumbnail','excerpt','editor','comments', 'custom-fields'); return $args; }
And the second one to alter the portfolio grid order (“custom_price” being the custom field):
function custom_post_grid_query( $query, $params ) { $query['orderby'] = 'meta_value'; $query['order'] = 'ASC'; $query['meta_query'] = array(array('key' => 'custom_price')); return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
Best regards,
JosueNovember 13, 2014 at 12:48 am #350509A big thank you for the quick response Josue.
Is it possible to use the “excerpt” value instead of “custom_price” for sorting?
Because I want to use it to display the prices in the “grid portfolio” in order not to have to enter the data twice.I prefer this because the website is bilingual (WPML) I’ll have to use a different format for the price. (“$” is after in french and is before in english)
I will provide you, my admin access and page link if it can be useful for you.
Thank you again.
November 13, 2014 at 12:55 am #350518This reply has been marked as private.November 13, 2014 at 12:56 am #350519This reply has been marked as private.November 13, 2014 at 2:15 am #350545Hi!
As far as i know that’s not possible, the main reason being that the excerpt can contain HTML tags which would cause a big mess if used as an orderby parameter, here’s the list of values you can set as orderby:
http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_ParametersCheers!
JosueNovember 18, 2014 at 9:22 pm #353246Again thank you for the reply,
When I add custom code, there are others that appear when the page is published.
Here is the list:
– breadcrumb_parent
– footer
– header_title_bar
– header_transparency
– layout
– sidebarIs it possible to not displayed?
Also, how can i display the price (custom_price field) in the portfolio grid (under de title) and in the portfolio page in order to enter the price only once?
Many thanks.
November 18, 2014 at 11:24 pm #353329Hi!
Try the following, open /enfold/config-templatebuilder/avia-shortcodes/portfolio.php and look for this part (~470):
$markup = avia_markup_helper(array('context' => 'entry_title','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)); $output .= '<header class="entry-content-header">'; $output .= "<h3 class='grid-entry-title entry-title' $markup><a href='{$title_link}' title='".esc_attr(strip_tags($title))."'>".$title."</a></h3>"; $output .= '</header>';
Change it to:
$markup = avia_markup_helper(array('context' => 'entry_title','echo'=>false, 'id'=>$the_id, 'custom_markup'=>$custom_markup)); $output .= '<header class="entry-content-header">'; $output .= "<h3 class='grid-entry-title entry-title' $markup><a href='{$title_link}' title='".esc_attr(strip_tags($title))."'>".$title."</a></h3>"; $output .= "CUSTOM META CODE HERE" $output .= '</header>';
To do this modification using child theme shortcodes:
http://kriesi.at/documentation/enfold/add-new-or-replace-advanced-layout-builder-elements-from-child-theme/Cheers!
JosueNovember 24, 2014 at 9:17 pm #357115Hello Josue,
I know a few basics in programming, but I’m not a programmer.
That said, I am not able to display the prices in the portfolio boxes.
I tried to replace “custom_markup” with “custom_price” that I use in my custom fields, but in vain.
And what does ($ output. = “CUSTOM META HERE CODE”)?
What should I replace it with “custom meta code here”?Note that I use a child theme and I added the command lines as mentioned in your answer.
I also replaced the lines requested in portfolio.php file I copied to my child theme.Here’s the code displayed in my functions file:
<?php /* * Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then. */ /* * add option to edit elements via css class */ // add_theme_support('avia_template_builder_custom_css'); // enable custom fields for Portfolio items add_filter('avf_portfolio_cpt_args', 'avf_portfolio_add_custom_fields', 1); function avf_portfolio_add_custom_fields($args) { $args['supports'] = array('title','thumbnail','excerpt','editor','comments', 'custom-fields'); return $args; } // alter the portfolio grid order function custom_post_grid_query( $query, $params ) { $query['orderby'] = 'meta_value'; $query['order'] = 'DESC'; $query['meta_query'] = array(array('key' => 'custom_price')); return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2); // Add new or replace Advanced Layout Builder elements from Child Theme add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1); function avia_include_shortcode_template($paths) { $template_url = get_stylesheet_directory(); array_unshift($paths, $template_url.'/shortcodes/'); return $paths; }
Again thank you for your help. :)
November 25, 2014 at 12:16 am #357252This reply has been marked as private.November 25, 2014 at 5:32 am #357337Hi!
You need to create a /shortcodes/ folder in your child theme directory and clone (+modification) the portfolio.php parent theme file there.
Now add a new folder in your child theme directory called shortcodes. If you copy an element from enfold>config-templatebuilder>avia-shortcodes to this folder it will replace the one in the parent and be used instead. You can also add new ones using the other shortcode elements as examples.
Cheers!
JosueNovember 25, 2014 at 9:39 pm #357957Sorry but I do not read everything considering I had to copy the same path as in the original folders of the theme.
By cons, if we simply returns the fact to sort items in portfolio price range with custom fields, it does not work.
It’s mostly what I need at the base.
I also removed the “Add new or replace Advanced Layout Builder Elements from Child Theme” to be sure it does not create conflict.
So here’s what’s in my functions.php file in the child theme:
<?php /* * Add your own functions here. You can also copy some of the theme functions into this file. * WordPress will use those functions instead of the original functions then. */ /* * add option to edit elements via css class */ // add_theme_support('avia_template_builder_custom_css'); // enable custom fields for Portfolio items add_filter('avf_portfolio_cpt_args', 'avf_portfolio_add_custom_fields', 1); function avf_portfolio_add_custom_fields($args) { $args['supports'] = array('title','thumbnail','excerpt','editor','comments', 'custom-fields'); return $args; } // alter the portfolio grid order function custom_post_grid_query( $query, $params ) { $query['orderby'] = 'meta_value'; $query['order'] = 'DESC'; $query['meta_query'] = array(array('key' => 'custom_price')); return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
Thank you.
PS – The extension “WPML” can there be a conflict?
November 26, 2014 at 5:22 am #358149Hey!
Alright. On portfolio.php, replace the code with this:
$output .= '<header class="entry-content-header">'; $output .= "<h3 class='grid-entry-title entry-title' $markup><a href='{$title_link}' title='".esc_attr(strip_tags($title))."'>".$title."</a></h3>"; $estate_price = get_post_meta( $the_id, 'estate_price', true ); $output .= "<span class='estate_price'>{$estate_price}</span>"; $output .= '</header>';
On functions.php, replace the order parameter with this:
function custom_post_grid_query( $query, $params ) { $query['orderby'] = 'meta_value_num'; $query['order'] = 'DESC'; return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
Create a custom field on the portfolio items called estate_price then enter a price value like $ 9.99. I know the custom fields is not a beautiful solution but it works. If you want something more sophisticated that this one, you might need to hire a freelance developer.
Regards,
IsmaelNovember 26, 2014 at 5:37 pm #358381Thank you Ismael,
This works for the display of the prices on the portfolio.php child theme. By the way, I replaced the variable “estate_price” by “custom_price ” because it was already used for all entries.
Sorting does not work though.
I tried to replace
$ query ['orderby'] = 'meta_value_num';
by
$ query ['orderby'] = 'custom_price';
but in vain.Any other ideas please?
- This reply was modified 9 years, 11 months ago by nparent.
November 27, 2014 at 1:00 pm #358975Hey!
You don’t need to replace the order parameters.
function custom_post_grid_query( $query, $params ) { $query['orderby'] = 'meta_value_num'; $query['order'] = 'DESC'; return $query; } add_filter( 'avia_post_grid_query', 'custom_post_grid_query', 10, 2);
Please apply custom fields with different value(example: $ 9.99, $ 8.99 and $ 7.77) on 3 posts then test it. Change DESC to ASC or vice versa.
Best regards,
IsmaelApril 26, 2016 at 9:41 pm #622536is it possible to see the live site on this to help other Enfold users?
Thanks
JonApril 27, 2016 at 11:28 am #622928That would be up to @nparent, i’ll leave this thread open.
Best regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.