• Resolved siegetheartist

    (@siegetheartist)


    I have a website consisting of a 10-15 pages.
    In one of my templates (lets call it Portfolio.php) I have an “includes” pointing to a php file where all of my hand coded functions reside.

    On the same template (portfolio.php), I want to add certain functions from my “my_functions.php” file into that template, depending on what page is currently being displayed.

    For example:

    the template “portfolio.php” needs to be able to display 2 functions if its on page1, 2 different functions if its on page2, an 2 other functions if its on page3 (all of the functions are being included by an external “my_functions.php” file).

    Im guessing all I have to do is:

    if (  is_page('page1') ) {
    function1();
    function2();
    
    } elseif ( is_page('page2') ) {
    function3();
    function4();
    }

    etc. etc.

    Only problem is, I don’t know what the built in wordpress function of “pages” is. Is it “is_page_template”? I don’t think it is as each page is featuring the same template. So if I were to use “is_page_template” it would never display different functions because each page would have the same template.

    Any suggestions?
    I hope I explained myself well. If not let me know and i’ll try and word it differently to explain myself better. Thanks for any help.

Viewing 1 replies (of 1 total)
  • Thread Starter siegetheartist

    (@siegetheartist)

    I found the codex on the wordpress site for the function to call a page. Its is_page() just like I had originally thought. The above code works like a charm.

Viewing 1 replies (of 1 total)

The topic ‘How do I display a specific function on a specific page’ is closed to new replies.