2 post a template

WordPress
8 June, 2020 11:07:30
famp
Topics: 3
Messages: 12
I have a field address in post called client and a field called address in post called properties, how can I link both posts in the template


8 June, 2020 12:23:54
E2Pdf
Support
Topics: 7
Messages: 3163
Hi,

If 2nd post is static, you must be able to use such shortcode: [meta key="custom_key" id="1"] where ID attribute is Post ID from which it must be rendered value.

If it's not static, it will be need to use custom filter to render value inside needed field based on how posts connected via filter:


add_filter( 'e2pdf_extension_render_shortcodes_pre_do_shortcode', 'custom_value_output', 10, 5);
function custom_value_output($value, $element_id, $template_id, $item, $dataset){
//$element_id - is the ID of Field inside E2Pdf Template, can be retrieved by "Right Mouse Click" -> "Properties"
//$dataset - is main Post ID
return $value;
}


We remain at your service.
We would really appreciate your feedback at WordPress.org!
9 June, 2020 08:43:43
famp
Topics: 3
Messages: 12
Hello
I can't get it to work.
I have used this:
[meta key = "garden" id = "4543"]
garden is the metakey in the postmeta and 4543 the post id.
I have also used it like this:
[meta key = "garden" id = "[meta key =" housing "]"]]
and the function is not really how to use it:
add_filter ('e2pdf_extension_render_shortcodes_pre_do_shortcode', 'custom_value_output', 10, 5);
function custom_value_output ($ value, $ element_id, $ template_id, $ item, $ dataset) {
$ value = $ item;
// $ element_id - is the ID of the field within the E2Pdf template, can be retrieved by right-clicking -> "Properties"
// $ dataset - is the main ID of the post
return $ value;
}
I have put this in the function
and in the template:
[e2pdf_extension_render_shortcodes_pre_do_shortcode element_id = '18 'template = '12' item = 'jardin' dataset = '4543']
I feel like an idiot, but I really don't know how to do it.
9 June, 2020 08:47:13
famp
Topics: 3
Messages: 12
reviewed
Hello
I can't get it to work.
I have used this:
[meta key = "jardin" id = "4543"]
garden is the metakey in the post goal and 4543 the post id.
I have also used it like this:
[meta key = "jardin" id ="[meta key ="vivienda"]"]
and the function is not really how to use it:
add_filter ('e2pdf_extension_render_shortcodes_pre_do_shortcode', 'custom_value_output', 10, 5);
function custom_value_output ($ value, $ element_id, $ template_id, $ item, $ dataset) {
// $ element_id - is the ID of the field within the E2Pdf template, can be retrieved by right-clicking -> "Properties"
// $ dataset - is the main ID of the post
return $ value;
}
I have put this in the function
and in the template:
[e2pdf_extension_render_shortcodes_pre_do_shortcode element_id = '18 'template = '12' item = 'jardin' dataset = '4543']
I feel like an idiot, but I really don't know how to do it.
9 June, 2020 12:13:11
E2Pdf
Support
Topics: 7
Messages: 3163
Hi.

It was just confirmed issue due the '0' value of meta key field. We released currently a hot-fix for it. To update plugin set please "E2Pdf" -> "Settings" -> "Release Candidate Builds" (Update from E2Pdf.com). Screenshot attached. Check for plugin updates, and update plugin to 1.11.02.1. It will fix issue with output of "0" value. After applying update it's recommended to turn off this option.

After update check please if following shortcode will output 0:
[meta key="jardin" id="4543"] (Keep attention, it must not be any spaces after and before "=").

If it will be okay and shortcode will output 0, let us know please if you need to make "4543" dynamic to be rendered from "vivienda" meta key of main post.

To output "4543" as dynamic we can prepare you steps with explanation how to complete this task or you can submit support ticket here: https://e2pdf.com/support/request so we can prepare it directly with your host. FTP access details also could be required to avoid any issues as it will be need to add PHP filter.

P.S. If you will fail with updating plugin to 1.11.02.1, download please attached file "e2pdf-wordpress.php.zip", unzip it and replace it via FTP at /wp-content/plugins/e2pdf/classes/extension/e2pdf-wordpress.php

We remain at your service.


We would really appreciate your feedback at WordPress.org!
9 June, 2020 13:18:21
famp
Topics: 3
Messages: 12
Hi.
When updating if it shows 0.
How should I do so that the id changes according to the post, in this template? We work with 2 main id's, from which you have to field their fields for both the post and the post-meta.
9 June, 2020 23:21:25
E2Pdf
Support
Topics: 7
Messages: 3163
Here is the example process to get data from 2nd post with dynamically saved post id:

1. Modify shortcode to: [meta key="vivienda" key2="jardin"] (screenshot 1)

Explanation:
* vivienda - meta key of main post which contains 2nd Post ID. (screenshot 2)
* jardin - meta key which must be output from 2nd Post ID

2. Install Code Snippets plugin: https://ru.wordpress.org/plugins/code-snippets/

3. Create New PHP snippet under installed plugin with code below: https://codeshare.io/ayOPye. Save and activate. (Screenshot 3,4)

4. Check the result. (screenshot 5)

We remain at your service.
We would really appreciate your feedback at WordPress.org!
10 June, 2020 13:14:58
famp
Topics: 3
Messages: 12
Hello,
everything went very well, but now I have another unexpected problem, we have to do it with post and post_meta
this example does not work [meta key = "client" key2 = "post_title"]
I suppose that it will be necessary to modify Post 2 Meta Value so that it reads besides the post_meta the post with that id plus the key, but I have tried to do it and I don't know how to do it.
Can you tell me thank you?
11 June, 2020 00:17:20
E2Pdf
Support
Topics: 7
Messages: 3163
Hi,

"post_title" is not saved under meta keys so here is modified function for snippet to output "post_title" for 2nd post: https://codeshare.io/G6Wdgg.

Replace "Post 2 Meta Value" function.

"client" must renders in Post ID from where you are trying to retrieve post_title. Also do not forget to remove any spaces inside shortcode between and after "=".

We remain at your service.
We would really appreciate your feedback at WordPress.org!
11 June, 2020 00:37:15
famp
Topics: 3
Messages: 12
Hello
I've got it to work by modifying the code like this here:
add_filter ('e2pdf_model_shortcode_e2pdf_wp_response', 'e2pdf_model_shortcode_e2pdf_wp_response_key2', 10, 3);
function e2pdf_model_shortcode_e2pdf_wp_response_key2 ($ response, $ atts, $ value) {
$ post_info = false;
$ post_info = get_post ($ response);
switch ($ atts ['key2']) {
case 'post_title':
$ response = $ post_info-> post_title;
break;
default:
if (isset ($ atts ['key2']) && $ atts ['key2']) {
$ post_meta = false;
if ($ response) {
$ post_meta = get_post_meta ($ response, $ atts ['key2'], true);
}
if ($ post_meta! == false) {
$ response = $ post_meta;
}
} else {
$ reponse = '';

}
}
return $ response;
}
With this form I get to get post data with different fields.
I don't know if there will be another more efficient way to do it.
Thank you so much
11 June, 2020 01:02:23
E2Pdf
Support
Topics: 7
Messages: 3163
The logic is the same, so it's just up to you which code to use. It will not be any difference in performance.

We remain at your service.


We would really appreciate your feedback at WordPress.org!