Ionic and wordpress Rest Api in Plugin WP Job Manager


#1

Hi! I’m new in Ionic coding and I’m trying to get jobs listings from the plugin wp job manager. I already have the output from rest api but now I don’t now how to reflect it in the html side in my ionic app. I mean:
I use this code to get post from my site

<ion-content>
  <ion-card *ngFor="let post of posts | async" (click)="openPost(post)" tappable>
    <img [src]="post.media_url | async">
    <ion-item>
      <ion-avatar item-left>
        <img [src]="getUserImage(post.authorId)">
      </ion-avatar>
      <h2>{{ getUserName(post.authorId) }}</h2>
    </ion-item>
    <ion-card-content>
      <ion-card-title>
        {{ post.title }}
      </ion-card-title>
      <div [innerHTML]="post.excerpt"></div>
    </ion-card-content>
  </ion-card>
</ion-content>

But I don’t know how to change the elements to show the job listings instead the post.

How can I do this?

Thanks for the help! :smiley:


#2

Hi @joelnoiret!
I am trying to integrate both Bookly and WP Job Manager into my app as well, to no success unfortunately.
I didn’t manage to even convert WP Job Manager into readable JSON.

However, it looks like you are using devdactic’s tutorial for the REST API? If so, the main issue is you are calling a post excerpt from the provider. What you need to do is pull the whole content from the specific post you have placed the plugin shortcode into and display that. Rather than using getList (which pulls a list of posts), you need to pull the content of a post/page using get(postId, options?: RequestOptionsArgs): Observable<Response>;

Please see the Git repository here which explains a lot: https://github.com/wordpress-clients/wp-api-angular

Incidentally, I already tried to do this and the result was…well…here’s a picture!


#3

Hi! Thanks for the answer. Indeed, I’m learning and using multiple tutorials about integration between ionic and wp api. The WP Rest api works fine, but I don’t know how to call the elements from the content. I mean, with the tutorial the posts works fine, but I don’t want the post section, I want the job listings (in my app they will be business listings). I’m trying to learn about business finder /near to me listings to show all the business and restaurants in my town. But I don’t know how. There is a tutorial about calling wordpress pages but I have the same issue, I’m new in this and I don’t know how to call all the contents ( business title, link, featured image, etc.).


#4

Hmm, I see your issue. The problem I had was that both Bookly and WP Job Manager do not support JSON output at this time so even if it is called in a provider or even within a page.ts, it doesn’t display correctly.

But in theory, you could try outputting just the plugin div as custom JSON element and call that instead. I think there was a Wordpress plugin that could generate custom JSON tags from within pages, but I cannot recall what it was or even if it still works (there have been a lot of updates since the spec was implemented by Wordpress itself…).