D
D
Dmitry2018-02-04 10:37:08
WordPress
Dmitry, 2018-02-04 10:37:08

How to write a plugin for wordpress?

Hello! I just started learning wordpress, I'm trying to write a photo gallery plugin, because I think that through writing plugins you can get to know wordpress more deeply than just pulling the layout. I am a beginner in php, and in everything else too, for this reason I ask for help from more knowledgeable people, how best to implement this photo gallery? The question is, to load images, I want to use the standard wordpress media loader, creating two database tables, one with the names of the galleries, the second to hold the photos attached to it, and their description, linking them using a foreign key. And here is the problem concerning the essence of the question, how best to implement all this. Since the media loader creates its own image databases, and if I understand correctly, the main thing for it is the id of the loaded photo. But I also need image IDs, but in this case I risk getting two photos with the same ID on the same page if I start creating my own (although the probability of this is, of course, very small). Another option is to load identifiers from the tables of the standard loader, and reload them into your tables, and use them to get image data from the media loader table. The disadvantage of this method is an extra database query, plus that I can have one image with a different description. Actually, this was the question, how best to implement image storage? And since I'm already here, I'll ask one more question, how wordpress implements the creation and updating of posts, and so on. (for example, the same photo galleries), check if the topic identifier exists, and if it exists, update it, and if not, create it, how so yes? Or use two different pages to create and edit posts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-02-05
@HeadOnFire

I think that through writing plugins you can get to know wordpress more deeply

You think correctly...
And then you start doing it wrong...
If you want to learn more about WordPress itself, don't invent stupid bicycles, read the documentation, tutorials and learn how to work with WordPress, based on WordPress, using the various WordPress core APIs, and don't create crutches where in this is not necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question