Jump to content

Multiple commands in one statement with a single line output?


cswake

Recommended Posts

Hi, I'm modifying the following PHP code from a Wordpress plugin:

 

/* Byline. */

if ( $instance['byline'] )
echo do_shortcode( "<p class='byline'>{$instance['byline']}</p>" );

/* Entry title. */

if ( 'widget' !== $instance['entry_container'] && $instance['entry_title'] && $show_entry_title ) {
the_title( "<{$instance['entry_title']} class='entry-title'><a href='" . get_permalink() . "' title='" . the_title_attribute( 'echo=0' ) . "' rel='bookmark'>", "</a></{$instance['entry_title']}>" );
}
elseif ( 'widget' !== $instance['entry_container'] && $show_entry_title ) {
the_title( "<a href='" . get_permalink() . "' title='" . the_title_attribute( 'echo=0' ) . "' rel='bookmark'>", "</a>" );
}

 

The output currently is:

[ December 13, 2010 ]

Post Title

 

I'm trying to combine the two so that the output appears on one line.  What is the operator to execute multiple command in one statement?

 

Thanks.

Link to comment
Share on other sites

What is the operator to execute multiple command in one statement?

 

I don't understand the question. What do you mean 'execute multiple command in one statement'?

 

if you want to put 2 strings together, just concatenate them with .

 

$str = "hello". " ". "world";
echo $str;
[code]

output:

hello world

Link to comment
Share on other sites

Sorry if I wasn't clear, I'm just asking how to combine the Byline section into the Entry title.  The end result as I imagine it would look something like (this code doesn't work, of course):

 

if ( $instance['byline']&& 'widget' !== $instance['entry_container'] && $instance['entry_title'] && $show_entry_title ) {
echo do_shortcode( "<span class='byline'>{$instance['byline']}</span>" ) && the_title( "<{$instance['entry_title']} class='entry-title'><a href='" . get_permalink() . "' title='" . the_title_attribute( 'echo=0' ) . "' rel='bookmark'>", "</a></{$instance['entry_title']}>" );
}

 

 

 

Link to comment
Share on other sites

dot (period) is the concatenation operator. so to combine the output of the 2 commands, you'd do something more like

 

echo do_shortcode( "<span class='byline'>{$instance['byline']}</span>" ) . the_title( "<{$instance['entry_title']} class='entry-title'><a href='" . get_permalink() . "' title='" . the_title_attribute( 'echo=0' ) . "' rel='bookmark'>", "</a></{$instance['entry_title']}>" );
}

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.