Skip to content

Commit

Permalink
Added tags support to post types
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-goncalves-unp committed Nov 9, 2022
1 parent 66560aa commit 6564c8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions includes/iotcat_elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function create_post_type() {

$args = array(
'labels' => $labels,
'taxonomies' => array('post_tag'),
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
Expand Down Expand Up @@ -114,6 +115,19 @@ private function get_website_link($website){
}


private function get_tags_input($tags_path){
$tag_input = array();
if(isset($tags_path) && $tags_path !== null){
foreach($tags_path as $tag_path){
if(count($tag_path)>0){
$tag_name = $tag_path[0]["name"];
array_push($tag_input,$tag_name);
}
}
}
return $tag_input;
}

private function get_tags_elements($tags_path){
$html = "";
if(isset($tags_path) && $tags_path !== null){
Expand Down Expand Up @@ -306,10 +320,13 @@ public function delete_subscription_elements($subscription_id){


private function create_post_element($id, $name, $description,$website, $embedded_url, $image_url,$tags_path,$original_id,$subscription_id,$last_update_timestamp){


$element = array(
'post_title' => $name,
'post_status' => 'publish',
'post_content' => $this->get_page_content($name,$description,$website,$embedded_url, $image_url,$tags_path),
'tags_input' => $this->get_tags_input($tags_path),
'post_type' => $this->post_type,
'meta_input' => array(
"description" => $description,
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Plugin Name: IoT Catalogue Integration
* Description: Display in WordPress content from IoT Catalogue
* Version: 1.2.0
* Version: 1.3.0
* Author: UNPARALLEL Innovation, Lda
* Author URI: https://www.unparallel.pt
*/
Expand Down

0 comments on commit 6564c8c

Please sign in to comment.