0
votes

When ever I paste a php query in my pages on wordpress under the text tab or in Divi builder's code module i find the code breaks into text.

I go to the preview or published view of the page and see the following:

'subjects', 'showposts' => 10 ) ); ?>

it appears to me that everytime I use ">", in my php code, it breaks and displays anything after it as text.

In efforts to test the displaying of custom field types and fields, Using CPT UI, i created the following custom post type:

Post Type Slug * subjects Plural Label * subjects Singular Label * subject

with a Advanced Custom Fields I created a field group:

Subject Descriptors: Date of Birth * date_of_birth Date Picker Sex * sex Checkbox

<?php 
    query_posts(array( 
        'post_type' => 'subjects',
        'showposts' => 10 
    ) );  
?>
<?php while (have_posts()) : the_post(); ?>
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>

I'm simply looking to display the name (post title) with the two custom fields of the custom post type on a page. I am not very knowledgeable on the topic and would appreciate any guidance.

1

1 Answers

1
votes

In both the text tab and Divi's code module you can only enter html, not php.

The php you enter is handled as html.
If you would inspect the html source code on the frontend you will see it just will put the full code as html.

If you want to do php code you will have to change php files.

Side note query_posts() is very bad for performance.