WordPress.org

Ready to get started?Download WordPress

Forums

function not run! (11 posts)

  1. maniiiiac
    Member
    Posted 4 years ago #

    hi

    i edited single.php in theme directory, i pu this code

    <?php 
    
    $tank = ($_GET['lang']); 
    
    if ($tank=="fa") {
         $myImage = "<IMG SRC =assets/img/scenert.png>";
    } 
    
    if ($tank=="en") {
         $myImage = "<IMG SRC =assets/img/scenerten.png>";
    }
    ?> 
    
    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    <div id="maincontainer">
    <div id="contentwrapper">
    <div id="contentcolumn" class="background:#999999 url() right no-repeat;
    ">
    <div class="innertube">test<?php print $myImage; ?></div>
    </div>
    </div>
    
    <div id="rightcolumn">
    <div class="innertube"> 
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    			</div>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>
    
     </div>
    </div>
    </div>
    
    	</div>

    in this line

    <div class="innertube">test<?php print $myImage; ?></div>

    <?php print $myImage; ?> not run in my page
    what's wrong??

    i tested myself code in a single page

    <?php 
    
    $tank = ($_GET['lang']); 
    
    if ($tank=="fa") {
         $myImage = "<IMG SRC =assets/img/scenert.png>";
    } 
    
    if ($tank=="en") {
         $myImage = "<IMG SRC =assets/img/scenerten.png>";
    }
    ?>
    <div class="innertube">test<?php print $myImage; ?></div>

    and works fine

  2. Nutrawee
    Member
    Posted 4 years ago #

    I think that it has been run, but the image didn't appear because the path is incorrect.

  3. maniiiiac
    Member
    Posted 4 years ago #

    path is correct, but i test with full path and it's not run

  4. Nutrawee
    Member
    Posted 4 years ago #

    1. If you use WP super cache, don't forget to deactivate it.
    2. Check that you properly pass correct lang value: fa or en

    If you try

    <div class="innertube">test<?php print 'test'; ?></div>

    I think you will see 'test' on your page.

  5. maniiiiac
    Member
    Posted 4 years ago #

    1. i'm not use Wp Super Cache
    2. yes, i see test in my page. . . it's work on print or echo with any text [like: 'test';]but not runs $myimage :)

  6. Nutrawee
    Member
    Posted 4 years ago #

    try

    <?php 
    
    $myImage = 'abc';
    $tank = ($_GET['lang']); 
    
    if ($tank=="fa") {
         $myImage = "<IMG SRC =assets/img/scenert.png>";
    } 
    
    if ($tank=="en") {
         $myImage = "<IMG SRC =assets/img/scenerten.png>";
    }
    ?>

    if you see abc on your page, it means the problem is $tank

  7. maniiiiac
    Member
    Posted 4 years ago #

    i say heretofore, that it's work with any test

    ------

    i test your code and i see ABC in any lang!

  8. Nutrawee
    Member
    Posted 4 years ago #

    Stay cool ... I'm trying to help you
    The php code has been run. So, it means the problem is $tank.

  9. maniiiiac
    Member
    Posted 4 years ago #

    i'm waiting for you Dear Zeally!

  10. Nutrawee
    Member
    Posted 4 years ago #

    Sorry, I have tried this code in my local and it work well.

    First, you have check the $tank value by using this code.

    <div class="innertube">test<?php print '[' . $tank . ']'; ?></div>

    If there is nothing in "[]", it means that your testing method is wrong.
    Your testing url should be like this

    localhost/mysite/post/?lang=en

  11. maniiiiac
    Member
    Posted 4 years ago #

    my testing URL not wrong!
    i installed qTranslate on my blog. . . the language change From this plugin.
    and i want to change one of my pictures in site with this Query (?lang)

    but above code works fine when qTranslate is Deavtive. . .and also not works when qTranslate is Active

Topic Closed

This topic has been closed to new replies.

About this Topic