Jump to content


Photo
- - - - -
Resolved

Adding Custom Fields Code To Functions.php



  • Please log in to reply
12 replies to this topic

#1 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 31 October 2012 - 04:21 PM

Hi there.

I played around with custom fields on a temporary site, added all the necessary code to the functions.php file and it all worked fine except when i added it to the base file functions.php - the page in the wp-admin / editor just went white / blank.

I am not sure what i did wrong, can anyone help.
This is the code i added:

Please Login or Register to see this Hidden Content


Edited by Simon_P, 31 October 2012 - 04:25 PM.
Added code tags


#2 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 31 October 2012 - 04:25 PM

You are missing the closing } at the end of your function, turning on WP_DEBUG in wp-config.php would have helped.

#3 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 31 October 2012 - 04:38 PM

Now if i was a progrmmer i might have spotted something as silly as that, thanks Simon_P.
Ca
n you suggest the best way to tackle adding custom fields? Using the built in custom fields or a specific plugin to do it.

This is for a client to edit and i want to make it as easy as possible.

Thanks.

Quintin.

#4 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 31 October 2012 - 04:42 PM

This plugin is about as simple as it gets:

Please Login or Register to see this Hidden Content



#5 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 31 October 2012 - 07:21 PM

Thanks Simon, will defiitly check it out.

A last question for now, how do i hide this entire line if there is nothing added into the field in the admin?
<h4 class="filmhdrnext">Duration:</h4> <?php echo $film_duration ?>

thanks.

#6 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 31 October 2012 - 07:28 PM

Use some logic...

Please Login or Register to see this Hidden Content



#7 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 31 October 2012 - 07:33 PM

Hey Simon, it still displayes the title "Duration"...

#8 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 31 October 2012 - 07:40 PM

Try this then...

Please Login or Register to see this Hidden Content



#9 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 01 November 2012 - 05:22 AM

Magic, thank you so much for your help - really appreciate it!

#10 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 01 November 2012 - 01:59 PM

Simon, i have another question.
Your solution <?php if ( '' != $film_country ) printf( '<h4 class="filmhdr">Country</h4>%s', $film_country ); ?> worked for all the fields except the url.

How would i do it for this - when i tried it, i keep getting errors.
<h4 class="filmhdr">Trailer</h4> <a class="lbpModal cboxElement" href="

Please Login or Register to see this Hidden Content

echo $film_link ?>">View the clip</a>

Thanks.

#11 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 01 November 2012 - 02:45 PM

Same

Please Login or Register to see this Hidden Content



#12 quinntinm

quinntinm

    Super Member

  • Members
  • 121 posts
  • Country: Country Flag

Posted 01 November 2012 - 03:22 PM

Cool, thank you - i see how that works now.

#13 mackenzie

mackenzie

    Advocate

  • Members
  • 333 posts
  • Country: Country Flag

Posted 01 November 2012 - 10:32 PM

The topic was marked as resolved.





Also tagged with one or more of these keywords: Resolved