Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:09:03+00:00 2026-05-31T12:09:03+00:00

Alright so I have a custom page template designed with javascript and php (lets

  • 0

Alright so I have a custom page template designed with javascript and php (lets call this page1). The javascript inserts a second custom page (page2) template which displays content inside a div called contained on page1.

The problem I have is

Fatal error: Cannot redeclare contentAd() (previously declared in /home/content/70/8886870/html/wp-content/themes/myTheme/functions.php:20) in /home/content/70/8886870/html/wp-content/themes/myTheme/functions.php on line 23

The function in question runs as part of a hook. This is not a question of a child theme’s functions.php being the same as the parent. This is far more complex..

I know precisely why this is occurring: Since page1 is the container for page2, the functions in functions.php run when the page is loaded (as it should). However, because page2 includes wp-blog-header.php (necessary for custom wp queries and metadata calls), when the javascript runs through page2 to insert its content inside page1, the very same functions.php runs again and causes the above error.

I’m looking for a way around this. The javascript runs automatically on page load through ajax. Page2 must exist outside of page1 – they cannot be merged in any way. Page1 and Page2 do NOT use the same hooks. Page2 in fact, doesn’t even call to function contentAd(). This is entirely an issue of functions.php executing more than once because of the ajax call.

Is there a way to prevent functions.php from executing on a given page? Otherwise, I’m open to your suggestions!

Page1:

<?php
/*
Template Name: Page1
*/
?>

<?php get_header(); ?>

<script type="text/javascript" src="../wp-content/themes/myTheme/insert.js"></script>
<div id="content">
    <div class="padder">
        <?php do_action( 'bp_before_blog_home' ) ?>
        <?php do_action( 'template_notices' ) ?>
        <div class="page" id="blog-latest" role="main">
        <div class="spacer" style="float:left;">&nbsp</div>

        <div class="spacer" style="float:right;">&nbsp</div>
            <ol class="row" id="updates">
                <div id="contained"></div>
            </ol>
        </div>
    </div>
</div>
<?php get_sidebar() ?>
<?php get_footer() ?>

insert.js:

$(document).ready(function() {
    $('#contained').load('../wp-content/themes/myThemes/page2.php');
});

Page2:

<?php include("../../../wp-blog-header.php"); ?>
A whole bunch of code sits in here but keeping the above line all by itself still produces the error hence my theory.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:09:05+00:00Added an answer on May 31, 2026 at 12:09 pm

    The functions within your functions.php file are wrapped in an if-block, similar to the following, yeah?

    if ( ! function_exists( 'contentAd' ) ):

    If not — they should be. This check should prevent that error from occurring and prevent unnecessary processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so I have this C++ image capturing class. I was wondering if I
Alright, currently I have my SWF hitting a php file that will go and
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
I have my own custom webpart. Inside this webpart I would like to display
Alright, I'll try to explain this the best I can. I have an iPhone
I'm having a little predicament switching between views, here. Alright, so, I have this
Alright so I have a php script which gets results from a DB, and
Alright lets say I have a cPlayer class that inherits from cOrganism , which
Alright I have an xml document that looks something like this: <xml> <list> <partner>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.