• I am converting a HTML site into wordpress and I seem to have the most of it sorted. However I need my user to be able to update 3 blocks of text on the home page and I would like to be able to control these through the post section of wordpress if possible. I have the following code I am using for the content. Is there a call I need to make for to be able to make these sections editable with posts?

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; endif; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Richard,

    Take a look at wp_query, you would have to be somewhat specific about either category. This page will tell you everything you need to know about wp_query => https://codex.www.ads-software.com/Class_Reference/WP_Query

    One example is to query by category and call a single post so that the latest post is always the one visible in the content box you are targeting.

    <?php 
    
    	$query = new WP_Query( array(
    			'posts_per_page'	=>	1,
    			'category' => 'movies'
    			));?>
    
    			<?php while ( $query->have_posts() ) : $query->the_post();?>
    
    			<?php the_title(); ?>
    
                <?php the_content(); ?>
    
                <?php endwhile;?>

    Hope this helps. You will probably need to do a query like this for each of the 3 blocks of text on the page.

    Thread Starter richard.harris

    (@richardharris)

    I will give it a go ??

    Richard

    N Ireland

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post PHP Code for wesite template’ is closed to new replies.