Change Variable to object for get_the_title()p
-
Okay, I have been beating my head against this for awhile now.
I am using the Advanced Custom Fields plugin to create custom fields for some custom post types I created. A lot of information needs to pass from one custom post type to the next. What I am working on right now is creating a title from a combination of two other post titles which the user selects in the custom fields.
IE: Select 1 – Select 2 Title
I have the code to do this, and I can even easily pull the post ID of the posts to be used in creating the titles. Here is where I am having a problem, and it may just be that I am too new at php. I want to use get_the_title(); to display the two titles. Currently, my code looks like this:
<?php $sa_customer_id = the_field('sa_customer'); /* Sets variable to post ID number, ie echo $da_customer_id writes 130*/ $sa_site_id = the_field('sa_site'); get_the_title($sa_customer_id) . " - " . get_the_title($sa_site_id) . " Audit"; ?>
The title displays correctly when I manually place in the post ID’s, but defaults when I use the variables. I realize now, I need to create an object for the variables, but I am at a loss for how to do this. Any help or suggestions would be greatly appreciated!
- The topic ‘Change Variable to object for get_the_title()p’ is closed to new replies.