Support » Fixing WordPress » How to insert php inside php…

Viewing 2 replies - 1 through 2 (of 2 total)
  • please re-post the code – and follow the forum guidelines http://codex.wordpress.org/Forum_Welcome#Posting_Code

    Thread Starter starflow

    (@starflow)

    I am using wp-favorites plugin in a classipress site

    My aim is to incle the ad price in the page layout in the favorites page

    I am trying to add some php code into the page template file, but not having much luck

    Here is the existing code:

    <?php
        echo "<div class='wpfp-span'>";
        if (!empty($user)):
            if (!wpfp_is_user_favlist_public($user)):
                echo "$user's Favorite Posts.";
            else:
                echo "$user's list is not public.";
            endif;
        endif;
    
        if ($wpfp_before):
            echo "<p>".$wpfp_before."</p>";
        endif;
    
        echo "<ul>";
        if ($favorite_post_ids):
            foreach ($favorite_post_ids as $post_id) {
                $p = get_post($post_id);
    			global $post;
    			echo "<li><h3>";
                echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a></h3>";
    
    			$price = get_post_meta( $post->ID, 'price' );
    			echo $price;
    
    			if(get_post_meta($item->post_id, 'cp_price', true));
    
                if ( get_post_meta( $post->ID, 'price', true ) ) cp_get_price_legacy( $post->ID ); else cp_get_price( $post->ID, 'cp_price' );
    
                echo "<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>";
                if(get_post_meta($post_id, 'images', true)) cp_single_image_legacy($post_id, get_option('medium_size_w'), get_option('medium_size_h')); else cp_get_image($post_id, 'medium', 1);
                echo "</a>";
                echo substr(strip_tags($p->post_content), 0, 250)."...";
                echo "<br />";
                wpfp_remove_favorite_link($post_id);
                echo "</li>";
               }
    
        else:
            echo "<li>";
            echo $wpfp_options['favorites_empty'];
            echo "</li>";
        endif;
        echo "</ul>";
        wpfp_clear_list_link();
        echo "</div>";
        wpfp_cookie_warning();
    ?>

    The php code I want to insert is:

    <?php if ( get_post_meta( $post->ID, 'price', true ) ) cp_get_price( $post->ID, 'price' ); else cp_get_price( $post->ID, 'cp_price' ); ?>

    How can I do this?

    I did just try adding the code like this:

    if ( get_post_meta( $post->ID, 'price', true ) ) cp_get_price( $post->ID, 'price' ); else cp_get_price( $post->ID, 'cp_price' );

    but it did not work ie: it does not call up the price and display it in the page

    Any help will be greatly appreciated – thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to insert php inside php…’ is closed to new replies.