Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Use ACF as permalink for result tile link
- This topic has 5 replies, 2 voices, and was last updated 5 years, 4 months ago by
Ernest Marcinko.
-
AuthorPosts
-
January 6, 2021 at 8:39 pm #31040
pbpyrojust18
ParticipantIs it possible to create an ACF to use as the permalink for a result tile, but still show the title, excerpt, button, etc.. on the tile? I saw this for the lite version https://wordpress.org/support/topic/using-acf-value-instead-of-permalink/ , but does it change the permalinks for all the results or just the ones were that ACF is filled out?
https://resources-marqeta-ms.pantheonsite.io/resources/
https://resources-marqeta-ms.pantheonsite.io/wp-admin/post.php?post=7423&action=edit
https://resources-marqeta-ms.pantheonsite.io/wp-admin/edit.php?post_type=resources-home
https://resources-marqeta-ms.pantheonsite.io/wp-admin/admin.php?page=asp_settings&asp_sid=2January 6, 2021 at 9:17 pm #31041pbpyrojust18
ParticipantI just edited the ASL code for ASP and it seems to work
add_filter( 'asp_results', 'asp_custom_link_meta_results', 10, 1 ); function asp_custom_link_meta_results( $results ) { // Change this variable to whatever meta key you are using $key = 'url_to_asset'; // Parse through each result item foreach ($results as $k=>$v) { if ( function_exists('get_field') ) $new_url = get_field( $key, $v->id, true ); // ACF support else $new_url = get_post_meta( $v->id, $key, true ); // Change only, if the meta is specified if ( !empty($new_url) ) { $results[$k]->link = $new_url; } } return $results; }Unless there is an updated snippet for ASP?
January 6, 2021 at 10:49 pm #31042pbpyrojust18
ParticipantIs it possible to have the ‘url_to_asset’ to open in a new tab?
January 7, 2021 at 11:43 am #31046Ernest Marcinko
KeymasterThat code looks perfectly fine to me, great job!
Well, you can configure the plugin to open all links in a new tab here: https://i.imgur.com/4ae6SNo.png
January 7, 2021 at 8:35 pm #31049pbpyrojust18
ParticipantI only need it to open a new tab for the ones that have text in the ACF. If you have a quick way to do that, that would be great. If not I will figure it out with some more PHP.
January 8, 2021 at 1:33 pm #31051Ernest Marcinko
KeymasterWell, for that I recommend the results templating, using a hook is not going to work with this in my opinion.
-
AuthorPosts
- You must be logged in to reply to this topic.