I have this code:
<?php wpfp_link();the_views(); ?>
On running, it shows:
Add to favorites. Views:6
I want it to show like below, with spaces.
Add to favorites. Views: 6
Any help would be appreciated.
<?php wpfp_link(): ?> blah blah blah <?php the_views(); ?>
You need to add some HTML and CSS,
<span><?php wpfp_link(); ?></span> <span style="float:right"><?php the_views(); ?></span>
Demo: http://jsfiddle.net/E4y7y/1/
Solution 2
<span style="display:inline-block;width:60%"><?php wpfp_link(); ?></span> <span style="display:inline-block;width:35%;" ><?php the_views(); ?></span>
Demo: http://jsfiddle.net/E4y7y/
Instead of "Add to favorites. Views: 6" you want "Add to favorites". Then you would have to take the_views(); out and since wpfp_link(); puts Add to favorites on the page you would have to get in wpfp_link(); and add before "Add" and after "Add". it would make Add portion of the text blue.
If you want to give it a space after wpfp_link(); basically wrap it with a span and give it a margin/padding right, that is the best way of doing that.
Like this;
<?php
echo "<span style='color:blue;padding-right:10px'>";
wpfp_link();
echo "</span>";
the_views();
?>
http://jsfiddle.net/ygkFc/
Its purely a CSS thing.It depends upon the DOM where are you trying to show the out put..
You can put them in separate DOM and apply margin or float and display as like you want..
<div style = "float:left"><?php wpfp_link();?></div>
<div style = "float:right"><?php the_views(); ?></div>
Related
I am trying to have the title and date break to two lines but they are currently running in one line.
PHP novice here needs help!
<span class="kb-topic__list-article-title"><?php echo esc_html(get_the_title()); echo nl2br(the_date());?> </span></a>
All you need to do is echo a line break and not use the nl2br() function:
<span class="kb-topic__list-article-title">
<?php
echo esc_html(get_the_title());
echo '<br>';
echo (the_date());
?>
</span>
As long as you're jumping in and out of PHP and HTML, I would separate the dynamic content from the HTML layout. You can accomplish your goal in this fashion with something like the following:
<span class="kb-topic__list-article-title">
<div>
<?php echo esc_html(get_the_title()); ?>
</div>
<div>
<?php echo (the_date()); ?>
</div>
</span>
You can then style the HTML elements however you need to in order to achieve the exact layout you're going for. However the above code will get you the basic effect of putting the output of your two functions on separate lines.
You can also:
<span class="kb-topic__list-article-title">
<?php echo esc_html(get_the_title());?>
<br>
<?php echo (the_date());?>
</span>
have the brake not in php
This is my code in the php file. excontent is an array, $rebuild is a string.
<div class="about-hero">
<h2><span class="accel"><?php echo $excontent[0] . " "; ?></span><?php echo $rebuild; ?> </h2>
</div>
This is what I get when I inspect the element:
<div class="about-hero">
<h2>
<span class="accel">
<p>
"Accelerate is a marketing agency located in NYC. A great blah blah blah."
</p>
</span>
</h2>
</div>
Any ideas why its putting in a p tag??? Its something with the PHP and I'm new to PHP. I tried it with just strings and it works fine. I'm changing the color of the first word in a sentence (following the design) the rebuild is the rest of the sentence. They both echo fine on their own and show the correct content.
I'm assuming the <p> tag is on the $excontent[0] variable. In this case, you could try removing all HTML tags from it:
<div class="about-hero">
<h2><span class="accel"><?php echo strip_tags($excontent[0]) . " "; ?></span><?php echo $rebuild; ?> </h2>
</div>
Or removing just the trailing and leading <p> and </p>:
<div class="about-hero">
<h2><span class="accel"><?php echo substr(trim(substr(trim($excontent[0]), 3, strlen($excontent[0]))), 0, -4) . " "; ?></span><?php echo $rebuild; ?> </h2>
</div>
Your Browser will not "put" something into your HTML without any reason.
The first result of the Array is the place you should look at. You didn't provided your PHP Code, but im sure that result is where you find the <p> Tag ...
Just try this in JavaScript:
alert(<?PHP echo $excontent[0]; ?>);
I need to replace this get_option('mycruisine_menu_page_url') with a link to an actual page. Can anyone tell me what I need to change to do this? Thanks so much in advance. Apologies if I somehow didn't get the code to display properly. Edit: When I say actual page, I mean a link I can put in like http://www.mydomian.com/nursery.html.
<span><?php esc_html_e('Click Here To Find Out More!','MyCuisine'); ?></span>
<div id="bottom-shadow"></div>
</div> <!-- end .container -->
this:
<?php $my_link = "http://google.com/"; ?>
<span><?php esc_html_e('Click Here To Find Out More!','MyCuisine'); ?></span>
//or
<span><?php esc_html_e('Click Here To Find Out More!','MyCuisine'); ?></span>
I am sure this is a fairly simple question to answer, but I am new to PHP, so I was hoping someone could help me solve this problem.
I have a dynamic navigation menu that works really well, but I want to remove the link from the current page in the menu.
Here is my code:
<div id="navigation_menu">
<?
foreach($pagedata->menu as $menuitem){
$class = ($menuitem->uri == $requesteduri) ? 'navigation selection' : 'navigation page_select';
?>
<div id="<?=$menuitem->uri?>" class="<?=$class?>">
<img class="nav_icon" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/<?=$menuitem->uri?>.png">
<h1><?=$menuitem->title?></h1>
<h2><?=$menuitem->description?></h2>
<img class="go" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/go.png">
</div>
<?
}
?>
</div>
Any help would be greatly appreciated. Thanks!
UPDATED CODE: (this is what works for me now)
<div id="navigation_menu">
<?
foreach($pagedata->menu as $menuitem){
$class = ($menuitem->uri == $requesteduri) ? 'navigation selection' : 'navigation page_select';
?>
<div id="<?=$menuitem->uri?>" class="<?=$class?>">
<img class="nav_icon" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/<?=$menuitem->uri?>.png">
<h1>
<?php if ($menuitem->uri == $requesteduri):?>
<?=$menuitem->title;?>
<?php else: ?>
<?=$menuitem->title?>
<?php endif;?>
</h1>
<h2><?=$menuitem->description?></h2>
<img class="go" src="<?=PROTOCOL?>//<?=DOMAIN?>/img/go.png">
</div>
<?
}
?>
</div>
I don't know what your loop is outputting, but you want to match your page name with the menuitem->uri. So you'd get your page name like.. (Put this outside the loop)
<?php echo base_name($_SERVER['REQUEST_URI']); ?>
find out what your loop is outputting (Put this in the loop):
<?php echo $menuitem->uri; ?>
Then you'd create an if statement to compare the current menuitem in the loop and the page request, this is just an example:
<h1>
<?php if (base_name($_SERVER['REQUEST_URI']) == $menuitem->uri):?>
<?=$menuitem->title?>
<?php else: ?>
<?=$menuitem->title;?>
<?php endif;?>
</h1>
Put a conditional around the anchor text to see if $menuitem->uri is equal to the current page URL, accessible from `$_SERVER['REQUEST_URI'] before outputting the anchor tags.
I'm having trouble writing an if else statement. Considering that I've been doing so for years in ColdFusion, this make me feel very stupid.
Here's the task.
I need to pull first name, last name, email, co-chair status from a database and return the results. However not everyone has an email, so I need a statement that will include a mailto link for those that have emails, and exclude a mailto link for those that don't.
Here's the code I'm using that includes the mailto link for all.
What adjustments do I need to make?
thanks,
david
<?php do { ?>
<?php echo $row_GetMembers['BACmember_First']; ?> <?php echo $row_GetMembers['BACmember_Last']; ?>
<?php /*START_PHP_SIRFCIT*/ if ($row_GetMembers['BACmember_CoChair']=="Yes"){ ?>
<strong> Co-Chair</strong>
<?php } /*END_PHP_SIRFCIT*/ ?><br />
<?php } while ($row_GetMembers = mysql_fetch_assoc($GetMembers)); ?>
This is the line of code you want to optionally display as a link (split for readability):
<a href="mailto:<?php echo $row_GetMembers['BACmember_Email']; ?>">
<?php echo $row_GetMembers['BACmember_First']; ?>
<?php echo $row_GetMembers['BACmember_Last']; ?>
</a>
You'll want something like this instead:
<?php if (!empty($row_GetMembers['BACmember_Email'])): ?>
<a href='mailto:<?php echo $row_GetMembers['BACmember_Email']?>>
<?php echo $row_GetMembers['BACmember_First']; ?>
<?php echo $row_GetMembers['BACmember_Last']; ?>
</a>
<?php else: ?>
<?php echo $row_GetMembers['BACmember_First']; ?>
<?php echo $row_GetMembers['BACmember_Last']; ?>
<?php endif; ?>
If the email field isn't empty (the ! negates the result, so we're checking if it isn't empty), it prints the first and last name inside an anchor tag. If it is empty, it prints the name without it.
A more elegant solution may be to provide the email address as a separate field or link, as opposed to having a list of some names that are links and some that aren't.