Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #40 from TakwimuAfrica/remove-geography
Browse files Browse the repository at this point in the history
[Hotfix] Remove geography custom fields
  • Loading branch information
KhadijaMahanga authored Jan 15, 2020
2 parents 9489e36 + e0894e3 commit 56cd5af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 106 deletions.
78 changes: 0 additions & 78 deletions wp-content/themes/hurumap/acf-json/group_5d91f54751c13.json

This file was deleted.

34 changes: 6 additions & 28 deletions wp-content/themes/hurumap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,43 +84,21 @@ function post_object_field_query($args, $field, $post_id)
// filter for every field
add_filter('acf/fields/post_object/query', 'post_object_field_query', 10, 3);
/**
* Preppend Geography Name on topic pages and profile pages
* Preppend Category Name on topic pages and profile pages
* Topic and Section titles often repeat for geographies
* Assists in selection
*/
function post_object_field_result($title, $post, $field, $post_id)
{
$geography_list = (object) [
'burkina-faso' => 'Burkina Faso',
'democratic-republic-congo' => 'DR Congo',
'ethiopia' => 'Ethiopia',
'kenya' => 'Kenya',
'nigeria' => 'Nigeria',
'senegal' => 'Senegal',
'south-africa' => 'South Africa',
'tanzania' => 'Tanzania',
'uganda' => 'Uganda',
'zambia' => 'Zambia'
];
//get geography of the post
$geography_slug = get_field('geography', $post->ID);
$geography = $geography_list->$geography_slug;
// append post geography to each post result
$title = $geography . ' : ' . $title;
//get category of the post
$category_name = get_the_category($post->ID)[0]->name ;

// append post category country to each post result
$title = $category_name . ' : ' . $title;
return $title;
}
add_filter('acf/fields/post_object/result', 'post_object_field_result', 10, 4);
add_filter('acf/fields/relationship/result', 'post_object_field_result', 10, 5);
/*
* Add geography column label to posts list
*/
function add_geography_column_label($columns)
{
//add geography label to existing column array
$columns['geography'] = __('Geography');
return $columns;
}
add_filter('manage_posts_columns', 'add_geography_column_label');

/*
* Add bidirectional link between profile section and topic
Expand Down

0 comments on commit 56cd5af

Please sign in to comment.