Forums

undefined function bloginfo (7 posts)

  1. piyashrija4489
    Member
    Posted 1 year ago #

    hi there

    i am making my first wordpress theme but got in trouble
    i have script.php file in theme folder
    i am using jquery to load it from index.php
    `$(document).ready(function(){
    var templatepath="<?php bloginfo('template_directory') ;?>" jQuery('ul#morepostul').load(templatepath+'/script.php'); }); `

    in script.php i have code like below

    <br />
    <?php</p>
    <p>echo bloginfo('template_url');</p>
    <p><?

    i dont know why i am getting this error
    Fatal error: Call to undefined function bloginfo() in /home2/agricul1/public_html/webtutsandseo/wp-content/themes/webtutsandseo/script.php on line 11

    please help i could not figure out what i am doing wrong from last 2 days

  2. piyashrija4489
    Member
    Posted 1 year ago #

    hey any there to help me its urgent
    thanks

  3. piyashrija4489
    Member
    Posted 1 year ago #

    hey their is no one in this forum to provide solN

  4. randinicole
    Member
    Posted 1 year ago #

    Please stop bumping your thread. It was still on the first page. Someone will come along and help.

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    shouldn't <p><?

    be <p>?>

    ?

  6. mattyza
    Member
    Posted 1 year ago #

    @RVoodoo is correct regarding your tag layout. If this code layout is imperative to your theme, I'd recommend <p><?php bloginfo( 'template_url' ); ?></p> as it's easier to read and follow. :)

    Regarding your query, is the script.php file being included/required via index.php? If not, the script.php file doesn't have access to all available WordPress functions, including bloginfo().

    On another note, it isn't recommended to mix PHP and JavaScript, as you have done in your example. There are other methods of achieving this result that keep the separation between the PHP (working layer) and the JavaScript ("animation"/DOM manipulation on client side layer).

    If you require the script.php file in index.php, you could also write:

    <?php require( 'script.php' ); ?>

    I hope this helps. :)

    All the best,
    Matty.

  7. piyashrija4489
    Member
    Posted 1 year ago #

    thank you all for reply

    @mattyza is there any tutorial to display post on wordpress using jquery, ajax
    i tried this but could not get thru
    http://wordpressthemescollection.com/ajax-wordpress-post-popup-with-simplemodal-and-jquery-488.html/comment-page-4

    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.