Link Custom Post Type with Page via Custom Fields
I have a dilemma that I’m hoping someone can help me with. I have a client wanting to display testimonials on each page of their website. Easy enough except they want to specify which testimonial appears on which page.
Mind you they would prefer not to use custom fields to add the testimonial since they don’t find custom fields user-friendly enough.
So my first thought was to create a custom post type labeled “testimonial”, a custom taxonomy labeled “testimonial tag” and write an if/else statement into the template file that basically said:
if page = about then display all testimonials with the “about” testimonial tag, else if the page = services display all testimonials with the “services” testimonial tag, else if …
The only problem with this solution is that they would have to add to the if/else statement as they created new pages and they’re not knowledgeable enough for that.
So my second thought is to keep the custom post type and possibly the custom taxonomy but write the if statement so that basically it checks if the page has a custom field value of say for example “show services testimonials” then WordPress displays all testimonials with the tag “services” on that page.
The trouble I’m running into is:
1) How can I link the page’s custom field value with the testimonial’s custom taxonomy? Instead of custom taxonomy could I use a custom field? For example, could I say if page’s custom field value = the testimonial’s custom field value then display those testimonials?
2) How do I write the statement so that all the client has to do is A) enter a label into the custom field of any new page they create then B) create new a tag in the custom taxonomy or enter a label into the custom field of any new testimonial they create and the testimonial will appear without having to touch the if statement.
Have any ideas? Any help with this will be much appreciated.
- The topic ‘Link Custom Post Type with Page via Custom Fields’ is closed to new replies.