I am trying to: I have tried different methods but I can not get it.
Link to a page where the issue can be seen:
The URL with correct background color: hidden link
The URL with error to get Parent Background Color: hidden link
I expected to see: I hope to see the background color
Instead, I got: Nothing.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hello,
Thank you for contacting our support forum.
Could you let me know where the background color is being retrieved from ?
Also could you let me know the code that is being used for this ?
Thanks,
Shane
Hello @Share, im using the try using the following code on my header.php
<?php $bg_color = do_shortcode( "[types field='color-del-curso' id='$parent'][/types]" );?>
<div class="content_inner" <?php echo "style='background-color:". $bg_color ."'";?>>
This code is able to apply the background color to the container as it appears in the url:
hidden link
The problem is that I can not make it apply to the child post, the $parent not work:
hidden link
This code has been tested to verify that if I read the ID of the post father and if he reads, but of course this would not be dynamic:
<?php $bg_color = do_shortcode( "[types field='color-del-curso' item='400618'][/types]" );?>
Other code base on you documentation:
<?php $bg_color = do_shortcode( "[types field='color-del-curso' item='@cursos-presenciales.parent'][/types]" );?>
I also tried to follow its documentation and it does not show me, anyway I do not know how to do it so that from PHP, which is where I am applying the fund, I get it from Post Parent.
Thanks.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Satiago,
How is the relationship between the posts done?
Is it a one-to-many relationship that was setup in Types?
Please let me know.
Thanks,
Shane
The relationship is by post.
Since the structure of the course is:
- Landing Page <-- This landing has all the fields that are filled in types.
----- Thanks page <-- This landing of thanks shows everything that I place in the Main Landing.
What does not work is the Parent within PHP
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
I see the issue now.
Try this.
$parent_id = wp_get_post_parent_id( get_the_ID() );
<?php $bg_color = do_shortcode( "[types field='color-del-curso' item="'.$parent_id.'"][/types]" );?>
Please Try this and let me know the results.
Thanks,
Shane
Hello @Shane ,
Thanks, it worked perfect and now the color changes without problems.
We can review the same problem but it is already internally related without PHP coding.
The teachers are loaded from the Main Landing but they are not showing in the child.
I have tried in this way, but it does not work.
Test 01
{!{wpv-view name='docentes-del-curso' item='@docentes-del-curso.parent' orderby='titúlo' order='asc' cached='off'}!}
Test 02
{!{wpv-view name='@docentes-del-curso.parent' orderby='titúlo' order='asc' cached='off'}!}
Thanks
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
So just to confirm here, you are trying to retrieve the child posts using this view correct? Are the parents being loaded on this page as well ?
Please let me know.
Thanks,
Shane
It is correct, the information displayed on the page is being obtained from the langing parent.
How could we do?
Check attachment:
Thanks
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
Mind if I took a look at where the view is added to the page?
The private fields will be enabled so that you can provide the credentials.
Thanks,
Shane
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
I dont think this one is going to be possible.
Because in order to select Karen Goldman to add to this page hidden link
You will need to be displaying something from its parent as well. From what I can see there isn't a reference to the parent on this page.
The other alternative is to manually specify the parent in the view to display the child post.
Thanks,
Shane
Hello, the profile Karen Goldman is loaded on "Parent" landing:
hidden link
And the idea is to show on the daughter page which is this:
hidden link
All of the more custom fields are loaded from the parent page and works perfectly but I can not do this with the teacher.
Thanks.-
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
You just want to load the child correct?
So what you can do is to set the view to get the parent ID by using a shortcode parameter. See Screenshot
Then you can pass the ID of the parent into this view and it should resolve the issue for you.
Thanks,
Shane
Can you make the configuration if it works?
Thanks!
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Santiago,
Since the site is in a different language it makes it difficult to navigate.
Can you point me to a point on the page on the backend that refers to the parent?
This will greatly help to make some linkage.
Thanks,
Shane