WORDPRESS: Is Custom Fields the solution for my portfolio?

前端 未结 2 1002
予麋鹿
予麋鹿 2021-01-27 06:17

Here\'s a brief explanation of what I\'m trying to do:

My homepage will have about 12 thumbnail images with title, short description, maybe web url (arranged 3 x 4 or wh

2条回答
  •  自闭症患者
    2021-01-27 06:41

    Custom fields are per post key-value pairs. So you could certainly use them for this purpose. For instance, you could have custom fields named exactly as suggested: image1, image2, etc. Note that the generic nature of custom fields does make this at least a little awkward, but it is probably still your best option.

    Those keywords must be processed somewhere, and it sounds as if your single.php is the place to do it. Essentially your single.php is a custom post template, so you can extract the custom field data and render it as you wish. You will need to write PHP code to do this, and be comfortable in reading the WordPress function reference.

    The get_post_meta function is probably the most relevant one, but see the others on the main reference.

    What you want to do isn't difficult, but is hard to do the first time. That's because you will be learning all sorts of little nuances of WordPress along the way.

提交回复
热议问题