• Resolved Neji87

    (@neji87)


    I’m trying to develop my first WordPress plugin and so far it’s gone well.

    I’ve created a plugin which creates a table in the database and I’ve also added a page in the admin backend to all users to insert data into a form which is then taken and added into the new table.

    Now I’m at a point where I want to create a function which shows the data in the table. Writing the function is no problem but how do I go about calling the function in a page? I want the homepage to show the data so I think I would need to call the function on the page.

    Any help would be great.

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

    (@ext103)

    you will need to find a “hook” (search the codex for all available hooks) that will put your function in the right place.

    then to call the function you would right it like this:

    say your function looks like this:

    function(){
    //do stuff here
    }

    when you call it you change a few characters like this:

    //calling the function
    function();

    if you are adding it to a hook (say for instance the “the_content” hook)

    add_filter('the_content', 'function', 99);

    if you just want it on the homepage you would probably need to add the is_home() check into the function before doing anything.

    Thread Starter Neji87

    (@neji87)

    Thanks, it works! I did have a look at hooks but couldn’t really get my head around them so thanks for the simple explanation!

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

The topic ‘Calling a function in the plugin file’ is closed to new replies.