Jump to content

Confused with coding for event page


OwlService

Recommended Posts

Hi there,

 

Thank you for your time. 

 

I am no PHP coder, so please bare with me.

 

I have the following code to display events on my page, but I want to change how date, event is displayed. Currently, it displays date in an H4 heading and directly below, the event title in an H5 heading.

I want it to display in one line 

<h4> Weds 1 June : Interval Training</h4>

i am sure this is a very basic thing to do, but I can't see it.

 

This is my code:

        <!-- Event Code To Go Here 
    ================================================== -->
    <div class="entry-content content">
	<div class="main-am-events">

		<?php $args = array(
		'post_type' => 'am_event',
		'post_status' => 'publish',
		'orderby' => 'meta_value',
		'meta_key' => 'am_startdate',
		'order' => 'ASC',
		'meta_query' => array(
			array(
				'key' => 'am_enddate',
				'value' => date('Y-m-d H:i:s', time()),
				'compare' => ">",
				),
				),
				);

		$the_query = new WP_Query($args); 
        
        if ($the_query->have_posts()) {
		while ($the_query->have_posts()) {
		$the_query->the_post();

		$postId = $post->ID;

		// GET EVENT DATA 

		$startDate = am_get_the_startdate('l j F');

		// DISPLAY EVENT CONTENT

		echo '<strong><h4>' . $startDate . '</h4></strong>';
		the_title( '<h5>', '</h5>' ); 
		the_content();
		echo '<hr class="x-hr">';

		}
		}
		wp_reset_query();
		?>
        </div><!-- end am-events -->

Could anyone give me a heads up please?

 

I appreciate your time.

 

Thank you,

Karl

Link to comment
Share on other sites

This doesn't require any programming skills, just common sense. Right now, you have this:

echo '<strong><h4>' . $startDate . '</h4></strong>';
the_title( '<h5>', '</h5>' ); 

That's an h4 elment with the data followed by an h5 element with the title (I have no idea what the strong element is doing there).

 

If you want to put the title into the h4 element, do it:

echo '<h4>'.$startDate.' : '.the_title('', '', false).'</h4>';

The third argument of the_title() tells Wordpress to return the title rather than print it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.