WordPress.org

Ready to get started?Download WordPress

Forums

Use plugin on specific page (6 posts)

  1. TWCrap
    Member
    Posted 1 year ago #

    Hello,

    First off all, i'm new to wordpress plugins, but my client requested it.

    I'm making an plugin for wordpress where an user can insert some data and blahblahblah...

    The problem is, the plugin must be only visible on 1 page.

    So how can i acief this. That the plugin will be actif on only one page? And how do i insert the content there then, Do i have to call an global function of my script that returns some HTML? Or do i have to do something diffrent?

    Thanks in advantage
    Marc

  2. bcworkz
    Member
    Posted 1 year ago #

    Depends on what that one page is. Front end, back end? Can it be identified in code somehow? Similar to the is_home() tag? Then just wrap any function calls to your plugin that generate output in an if() block on the page template.

    Another possibility. If any users that have page publish capabilities can be trusted to not use a particular template, you could call your plugin functions from that one template, create the one page based on it, and then simply create no more pages from that template.

  3. TWCrap
    Member
    Posted 1 year ago #

    it's an front-end plugin.

    and how do you mean this part:

    Can it be identified in code somehow?

    And how would that second option look then? because i can't find an option where you can select wich template to use... mayby i'm overlooking to it, but i'm just compleet new to wordpress

  4. bcworkz
    Member
    Posted 1 year ago #

    To identify in code. Hard to say specifically as there are many possibilities, but only some, or maybe none may apply to your unique situation. It may be as simple as "if the current post ID equals a number, show the plugin content".

    Page template. I'm referring to the WP definition of page, a special static post type, not a generic web page. When creating a new page (different than new post) there's a pull down field for which template to use in the page attributes block. To have your template show up here, the file needs to be in your theme folder and have a particularly formated first few lines identifying it as a template.

  5. TWCrap
    Member
    Posted 1 year ago #

    @ak75963, i will take a look at that

    @bcworkz, where can you select an difrnt template then? because i don't see an option like that when i create an new page...

  6. bcworkz
    Member
    Posted 1 year ago #

    Pull down the screen options tab and check mark Page Attributes under Show on Screen.

Topic Closed

This topic has been closed to new replies.

About this Topic