Support » Fixing WordPress » Call to undefined function get_header()

  • Hello, when I try to load my site this error shows. (line 14)
    Here is index.php:

    get_header(); ?>
    <div id=”primary” class=”site-content”>
    <div id=”content” role=”main”>
    <?php if ( have_posts() ) : ?>
    <?php dsframework_content_nav( ‘nav-above’ ); ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( ‘content’, get_post_format() ); ?>
    <?php endwhile; ?>
    <?php dsframework_content_nav( ‘nav-below’ ); ?>
    <?php elseif ( current_user_can( ‘edit_posts’ ) ) : ?>
    <article id=”post-0″ class=”post no-results not-found”>
    <header class=”entry-header”>
    <h1 class=”entry-title”><?php _e( ‘No posts to display’, ‘dsframework’ ); ?></h1>
    </header>
    <div class=”entry-content”>
    <p><?php printf( __( ‘Ready to publish your first post? Get started here.’, ‘dsframework’ ), admin_url( ‘post-new.php’ ) ); ?></p>
    </div>
    </article>
    <?php endif; ?>
    </div>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    • This topic was modified 3 years, 2 months ago by szelkoffy.
Viewing 14 replies - 1 through 14 (of 14 total)
  • What is the exact error message? Please post a url.

    Fatal error: Call to undefined function get_header() in /home/wik007/domains/wiktorjankowski.com/public_html/index.php on line 14

    Sorry, forgot that there are more lines.
    <?php
    /**
    * The main template file.
    *
    * This is the most generic template file in a WordPress theme
    * and one of the two required files for a theme (the other being style.css).
    * It is used to display a page when nothing more specific matches a query.
    * E.g., it puts together the home page when no home.php file exists.
    * Learn more: http://codex.wordpress.org/Template_Hierarchy
    *
    * @package dsframework
    * @since dsframework 1.0
    */
    get_header(); ?>
    <div id=”primary” class=”site-content”>
    <div id=”content” role=”main”>
    <?php if ( have_posts() ) : ?>
    <?php dsframework_content_nav( ‘nav-above’ ); ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( ‘content’, get_post_format() ); ?>
    <?php endwhile; ?>
    <?php dsframework_content_nav( ‘nav-below’ ); ?>
    <?php elseif ( current_user_can( ‘edit_posts’ ) ) : ?>
    <article id=”post-0″ class=”post no-results not-found”>
    <header class=”entry-header”>
    <h1 class=”entry-title”><?php _e( ‘No posts to display’, ‘dsframework’ ); ?></h1>
    </header>
    <div class=”entry-content”>
    <p><?php printf( __( ‘Ready to publish your first post? Get started here.’, ‘dsframework’ ), admin_url( ‘post-new.php’ ) ); ?></p>
    </div>
    </article>
    <?php endif; ?>
    </div>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Line 14 is “get header”

    That is not a WordPress index.php file.

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );

    The above is the index.php file.

    It sounds like the index file for a theme, though. Could it be a theme uploaded to the wrong directory?

    I uploaded theme to the public_html folder, well I guess it should be there. I don’t know anything about html/php/mysql

    Your theme should be uploaded to the wp-content/themes folder. If WordPress is installed directly to the public_html folder, wp-content should be a folder in public_html. If you’ve installed WordPress in a subfolder (for example, “wordpress” or “mysite.com”) inside of public_html, you’ll find wp-content inside that folder. You should move all your theme files into a single folder named for your theme (“twentyseventeen”, for example), inside the wp-content/theme folder.

    So your folder structure should look something like this:
    public_html/wp-content/themes/my-theme/index.php (and all the other theme files)

    or:

    public_html/my-site/wp-content/my-theme/index.php (and all the other theme files)

    Make sure you only move the theme files to this folder. WordPress core files should stay in either the public_html or my-site folder, depending on your file set-up. Depending on how complicated your theme is, it may be easier to remove everything, reinstall WordPress, and re-upload the theme to the right folder.

    Hope that helps.

    View post on imgur.com


    these are the only folders i have – last screenshoot shows folder inside domains and the rest is inside public_html folder

    • This reply was modified 3 years, 2 months ago by szelkoffy.

    So I think the problem is that WordPress isn’t installed at all, just your theme. You need both: WordPress is the application that powers the site and manages all the content, your theme is a customized library that WordPress uses to determine how the site should look.

    Assuming you downloaded the theme from somewhere? Do you still have the download on your local computer?

    If the answer is yes, then I would delete everything in the public_html folder and start over. First step will be to install WordPress itself. Your host may provide an easy one-click way of doing this, but if not, here are some instructions for manually installing it: https://codex.wordpress.org/Installing_WordPress

    Then, you can re-upload your theme into the wp-content/themes/my-theme (change my-theme to the name of your theme) folder. Then things should start working.

    (if you don’t still have the download, you can probably download everything from your current public_html folder through whatever file manager you are using. Then delete it all from the server and start fresh)

    Hope that helps!

    Thank you so much, it helped a lot. Luckily my host has an option to automatically install wordpress. But there is still one thing left, how can I make the site read my theme as the main theme? There are 3 more if I delte them and leave only mine the site is blank.

    From the Appearance>Themes menu in your WP admin panel, click on the theme you want, then click the “Activate” button. No need to delete the other themes.

    View post on imgur.com


    Some files were missing, like linki.php and meta.php so I added them from the old website which this theme was based on I guess. But why does this error keep showing even if they are in include folder? (obviously they are uploaded through the filezilla but just wanted to show that they are inside)

    whole home.php:

    http://pastebin.com/dTKn7LL8

    • This reply was modified 3 years, 2 months ago by szelkoffy.

    You should really do some reading. Copying and pasting files just because they worked somewhere else will get you nowhere.

    https://codex.wordpress.org/Main_Page

    But there ais every needed file inside this folder which causes the error, so why can’t it read them correctly?

    • This reply was modified 3 years, 2 months ago by szelkoffy.
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Call to undefined function get_header()’ is closed to new replies.