WordPress.org

Ready to get started?Download WordPress

Forums

PHP in Custom Field (4 posts)

  1. Raid33
    Member
    Posted 5 years ago #

    I'm trying to find a way to get this code to work in a custom field:

    <?php $recent = new WP_Query("cat=4&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>

    This is the code I'm trying:

    <?php echo stripslashes(get_post_meta($post->ID, "stories", true)); ?>

    When I load the page, all I get is this: have_posts()) : $recent->the_post();?>

    All I really need is a way to change the category of the posts for every page. Thank you for any ideas.

  2. Raid33
    Member
    Posted 5 years ago #

    thanks for any pointers.

  3. malakhi
    Member
    Posted 5 years ago #

    I want to execute PHP in a custom field, too, but I haven't found a solution yet.

    I just want to include a PHP file. Right now I have Exec-PHP installed and I can run PHP within my posts and pages, but not in the custom fields.

    Does anyone know how to do this?

  4. EntarteteMuzak
    Member
    Posted 5 years ago #

    Same problem.
    I'm running run-PHP and want to add

    <ul>
    <?php wp_list_bookmarks('category=2&show_description=1&title_before=<h3>&title_after=</h3>'); ?>
    </ul>

    to my custom field by using

    <?php $key="Linklist"; echo get_post_meta($post->ID, $key, true); ?>

    I even tried

    <ul>
    <?php wp_list_bookmarks('category=<?php $key="Linklist"; echo get_post_meta($post->ID, $key, true); ?>&show_description=1&title_before=<h3>&title_after=</h3>'); ?>
    </ul>

    but it seems like wp doesn't tolerate php in template tags.

Topic Closed

This topic has been closed to new replies.

About this Topic