Out put custom function with ACF fields

February 18, 2021 16:47:03
schwab
Topics: 2
Messages: 10
Hi, I need to output a custom function via ACF fields. I didnt really get yet how this works:

add_filter('e2pdf_model_shortcode_e2pdf_wp_response', 'e2pdf_model_shortcode_e2pdf_wp_response_imodatens', 10, 3);

function e2pdf_model_shortcode_e2pdf_wp_response_imodatens($response, $atts, $value) {
if (isset($atts['key']) && $atts['key'] == 'imodatens') {

$id = isset($atts['id']) ? $atts['id'] : false;

if ($id) { // Getting Post ID
$wohnflaeche = get_field('wohnflache', $id);
$grundstuecksflaeche = get_field('grundstuecksflaeche', $id);
$schlafzimmer = get_field('schlafzimmer', $id);
$badezimmer = get_field('badezimmer', $id);
}
}
$response = '<strong>Grundstücksfläche:</strong> '.$grundstuecksflaeche.' <strong>Wohnfläche: </strong>'.$wohnflaeche.' <strong>Schlafzimmer:</strong> '.$schlafzimmer.'<strong> Badezimmer:</strong> '.$badezimmer;
return $response;
}


My template shortcode "[e2pdf-wp key="imodatens"]" is working, but all the other shortcodes are messed up - they all show my $response content now. But i only want the $response output there where i put the shortcode in.

Thanks four your help
February 18, 2021 17:02:29
E2Pdf
Topics: 7
Messages: 3617
Support
Hi,

Here is corrected code: https://codeshare.io/5ZgWmn

$response = 'Grundstücksfläche: .... ' must be inside $id condition.

We remain at your service.


We would really appreciate your feedback at WordPress.org!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.