• paulwallas

    (@paulwallas)


    Hello

    I am looking to use the WP Custom Fields to add images to my portfolio pages.

    What i want to do is this:

    * Use the key for the image name
    * Use the value for the image itself
    * When using the value i want to only add in the image name and not the image type (.gif, .jpg)
    * This is becuase within the php i want it to have an image string that pulls the image name and the image type will already be defined.

    Anyone who can help or point me in the direction of a possible plugin would be a star.

    thanks

Viewing 1 replies (of 1 total)
  • stvwlf

    (@stvwlf)

    You are going to find it difficult to implement your plan the way you envision it. The reason is, for the PHP to be able to find your custom field, it has to know the name of the custom field’s key. If the key is different on each post, the PHP has no way to know which custom field it is supposed to retrieve.

    You can either create two custom fields, with keys of
    ImageName and ImageFileName
    and values of the name of the image, and the image’s filename less the extension

    or else make one custom field with a key of Image where the value is the name followed by a comma and then the filename, both in one custom field. The PHP will then split the two pieces of information apart.

    If you post back how you want to proceed I can help you with the PHP code. You should also include what you want the output in the theme to be – a link? to display of the image? where does the name get displayed?

Viewing 1 replies (of 1 total)
  • The topic ‘How to add images within custom fields’ is closed to new replies.