WordPress.org

Ready to get started?Download WordPress

Forums

where i put an include ?? (12 posts)

  1. Marcomail
    Member
    Posted 7 years ago #

    I have a php include in the header
    <?php include('include.php'); ?>

    but when i put it i receive a lot of error from wordpress and all the function don't work.

    where i put it ?

    The include connect to the db, it's acsript fro tracking people...is this the problem ?

  2. maerk
    Member
    Posted 7 years ago #

    Could you post the code for the header.php file?

  3. Marcomail
    Member
    Posted 7 years ago #

    it's strange...i put in the header the include and ond't work...i put the same in the index.php of template and it works

    <? include('./tts/in.php'); ?>

    why ?

    This is the header.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

    <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>

    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->

    <style type="text/css" media="screen">
    @import url( <?php bloginfo('stylesheet_url'); ?> );
    </style>

    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />

    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    <?php wp_get_archives('type=monthly&format=link'); ?>
    <?php //comments_popup_script(); // off by default ?>
    <?php wp_head(); ?>

    </head>

    <body>

    <div id="main" >

    <div id="containerleft">

    <div id="logon"></div>

    <div id="body">

    <?php get_sidebar(); ?>

    <div id="box">

      <?php wp_list_cats('sort_column=id&optioncount=1&exclude=6'); ?>

    </div>

    <div id="content">
    <!-- end header -->

  4. maerk
    Member
    Posted 7 years ago #

    What does include.php do?

    You mention it connects to the DB, what does it do with that connection?

  5. maerk
    Member
    Posted 7 years ago #

    Oh, I just read it tracks people. If it doesn't actually generate any output for the browser, index.php is probably the best place to put it!

  6. Marcomail
    Member
    Posted 7 years ago #

    But it's not the same ? I don't understand beacuse it doesn't work on header. this is the code of include:

    [long code removed - always post long code to a pastebin service]

  7. maerk
    Member
    Posted 7 years ago #

    I'm not really sure, I've noticed that sometimes things don't work when I put them in header. I have a hunch that it's because index.php is the "main page", and header.php gets included into it -- but somehow has "lower privileges".

    I'm not entirely sure of the mechanics, though.

  8. Marcomail
    Member
    Posted 7 years ago #

    with the include i ahve some trouble..for example.

    In the index.php if i put the include before this i can't show the rating

    <?php if(function_exists('the_ratings')) { the_ratings(); } ?>

    If i put the include at the bottom of the index.php rating is showed...why there are all this conflict ?

  9. Marcomail
    Member
    Posted 7 years ago #

    other ideas ?

  10. maerk
    Member
    Posted 7 years ago #

    Is there a particular problem with putting your include at the bottom of index.php?

    If it works, what's the problem?

  11. Marcomail
    Member
    Posted 7 years ago #

    It works but for me it's not the best place, yesterday for example i have receive another error...i have add the include in wp-blog-header.php and it works.

    Which is the best place to put it, now i have put it at the top...but i can include better ?:

    <?php
    include ("in.php");
    ?>
    <?php

    if (! isset($wp_did_header)):
    if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
    if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin') ) $path = '';
    else $path = 'wp-admin/';
    die("There doesn't seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.");
    }

    $wp_did_header = true;

    require_once( dirname(__FILE__) . '/wp-config.php');

    wp();
    gzip_compression();

    require_once(ABSPATH . WPINC . '/template-loader.php');

    endif;

    ?>

  12. maerk
    Member
    Posted 7 years ago #

    I'm not really sure, to be honest. You might try putting it in index.php -- the one that lies in the root directory. Eg, if your blog was at example.com/blog, put it in example.com/blog/index.php.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.