Skip Navigation

[Resolved] custom title for post , part 2

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Akhil 5 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1185641

hi. sometime ago norman gave me workaround:https://toolset.com/forums/topic/custom-post-title-from-5-different-custom-fields/
to auto rename the post title. its working well.
now i need simple php codes to detect the value.

to cut short i have this..
....
$field_1 = $postarr['wpcf'][project-name']; //select field

if(!isset($field_1) and $field_1 == 'Major') //value 1
$title .= 'Major Project';

if(!isset($field_1) and $field_1 == 'Minor') //value 2
$title .= 'Minor Project';

if(!isset($field_1) and $field_1 == ' ') //value 3
$title .= 'No Project';

am i doing something wrong here ?

#1185689

if(isset($field_1) and $field_1 == 'Major')
{$title .= ' ***[Major Project] ';}
if(isset($field_1) and $field_1 == 'Minor')
{$title .= ' [Minor Project] ';}
if(isset($field_1) and $field_1 != 'Major' and $field_1 != 'Minor')
{$title .= ' No Project ';}

i manage to solve this halfway. wonder if this is acceptable or better way of doing it ? thanks

#1185706

Hi Dee,

Your updated code looks good and you can further shorten it up as:


if(isset($field_1) and $field_1 == 'Major')
{$title .= '***[Major Project]';}
elseif(isset($field_1) and $field_1 == 'Minor')
{$title .= '[Minor Project]';}
else
{$title .= 'No Project';}

regards,
Waqar

#1185722

yes, thats good thanks waqar.