Minesh,
Are you still online? Wanted to try and see if you could help me build this out with PHP rather then views.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - tell me where and with which file you need help with?
The file in the theme is template-events.php. The URL is hidden link
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - I need FTP access details to access your file.
I have set the next reply to private which means only you and I have access to it.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Ok - I got the file and I can see it, sorry, not skype support provided.
What you want to display now? where is the exactly issue? Can I a demo link using which you want to build such filter?
Minesh,
I'd like to build out the page using PHP rather then Views as that seems to be where I'm having trouble.
My Views template for that page looks like this:
<div class="events-result-item" data-item-type="[types field='event_category'][/types]" data-capabilities='[acf_practice_areas]' data-people='[]'>
<div class="details">
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-calendar.svg" alt="calendar">
<span class="date">[types field='event_date' style='text' format='M j, Y'][/types]</span>
</div>
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-clock.svg" alt="clock">
<span>[types field='event_time'][/types]</span>
</div>
<div>
<img src="/wp-content/themes/cohenseglias/images/ion-location.svg" alt="location">
<span>
<span>[types field='event_location'][/types]</span>
</span>
</div>
</div>
<a href="[wpv-post-url item="@event_dates.parent"]">[wpv-post-title item="@event_dates.parent"]</a>
</div>
The reason I used Views is because that's the documentation I could find for RFGs. If you can help me rebuild this using PHP, I can then add in the relationship fields from ACF using our traditional PHP code.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - I need clear instructions what should be your expected output and what you want to achieve.
I think it can be doable using views easily but I need to understand first clear flow, where exactly you want to display the view and from where the results are coming.
When displaying repeating field group, you should select the desired repeating field group you want to display. See how you can display the repeating field group using view:
=> https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups
I do not understand why you chose Event as well as view's content as well as repeating field group. So please, lets do it step by step so I can lead you to the solution.
Views is doing the job correctly right now but I need to expand upon it to add in a relationship field from Advanced Custom Fields (ACF). Right now Views is displaying the Events in the way we want but there are data attributes in the div that we need to feed in relationship data from ACF (practice areas and people) so we can handle the filtering on the page.
It sounds like setting it up via a shortcode could be an option but I'm not able to get that to work which is why I thought setting this entire thing up with PHP, instead of Views, could be the better solution as I have a better understanding of how to use Types and ACF with PHP (just not with the RFGs).
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Ok but shortcode will do the work very easily. Could you please tell me if you have added shortocde that I shared? If yes- where?
I added the following code to /functions/custom_functions.php
add_filter('wpv_custom_inner_shortcodes', 'prefix_add_my_shortcodes');
function prefix_add_my_shortcodes($shortcodes) {
$shortcodes[] = 'acf_practice_areas';
return $shortcodes;
}
function func_get_practice_areas( $atts ){
$posts = get_posts(array(
'post_type' => 'practice',
'showposts' => 1,
'meta_query' => array(
array(
'key' => 'practice_areas', // name of custom field
'value' => 1045, // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
if( $posts ):
foreach( $posts as $post):
setup_postdata($post);
$pa_title = get_the_title();
return "$pa_title test";
endforeach;
endif;
}
add_shortcode( 'acf_practice_areas', 'func_get_practice_areas');
Then in the View, I added [acf_practice_areas] to the data-capabilities tag but nothing is output.
I still feel like doing this in PHP would be the easiest for me.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - the thing is that custom shortcode added to custom functions.php file is not running on your site and I do not know why.
I'v tried to check with really static value:
<input type="hidden" value="[display_practice_areas2]" name="mytestfield" />
And added following to functions.php file:
function func_display_practice_areas2(){
return "hello";
}
add_shortcode( 'display_practice_areas2', 'func_display_practice_areas2');
Strange thing is that I can see output as expected on my test install:
<input type="hidden" value="hello" name="mytestfield" />
But on your install the shortcode does not parse:
<input type="hidden" value="[display_practice_areas2]" name="mytestfield" />
Could you please first try to make the simplest custom shortcode work on your site.
Can you verify you are using the right site? I'm seeing changes made to the live dev site but not to the staging site that I setup for you. It looks like you may have logged into the live dev wordpress admin instead of the staging.
hidden link is what you should be using.
This might be why your tests aren't working correctly.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Why cant I see the view added to events page here?
=> hidden link
I can see nothing on the events page:
=> hidden link
Looks like the Template for that page wasn't set correctly in the staging site. I've fixed that and it should display properly now for:
hidden link
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Ok - I made progress and now I can see that the data-capabilities attribute has now correct results.
=> hidden link
This is the code added to custom functions.php file:
function func_get_practice_areas2( $atts ){
global $post;
$post_id = $atts['pid'];
$posts = get_field('practice_areas',$post_id);
if( $posts ):
foreach( $posts as $post):
setup_postdata($post);
$pa_title .= get_the_title().' ';
endforeach;
return $pa_title;
endif;
}
add_shortcode( 'acf_practice_areas2', 'func_get_practice_areas2');
This is how the attribute is called:
data-capabilities='[acf_practice_areas2 pid="[wpv-post-id item='@event_dates.parent']"]
Now, you can adjust your content as per your need. There is no fault of Toolset here. I think it just needs adjustment with your HTML structure and its associated attributes.