• Resolved GarrettB

    (@garrettb)


    Hi
    I have had a certain amount of success in writing the backend code for database search query.
    The code, which is a mixture of PHP and HTML allows the user to enter a search tern, and then the result are displayed.
    To do this, I have one function, and an associated short code.
    So I place the short code on the WordPress page, I place my function in my own function file and folder, and I include the shortcode information in the functions.php.
    So everything works, but I know this is not the ideal was to do things.
    I don’t fully understand loops etc., but I know there are certain times/places where you should hook into the main WordPress code.
    So my question is: Can anyone explain to me, in simple terms, if there is a better / more preferred way of achieving this functionality?
    Thank you
    Garrett

Viewing 2 replies - 1 through 2 (of 2 total)
  • I have done things very much like this.
    Instead of putting the code and registering the shortcodes in your theme’s functions.php I put mine into a plugin file.
    I have also on occasions put code into page templates, this let me link displays and lists of data in body text and widget areas.
    All these techniques work, some require different programming approaches. Some have different implications of entangling themes with functionality.

    Thread Starter GarrettB

    (@garrettb)

    Thank you Ross 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘A better way to write code’ is closed to new replies.