In the php file I have the following code
<div class="entry-meta">
<?php echo theme_post_meta(); ?>
</div>
The function theme_post_meta calculates and returns html that has two spans.
<span class="posted-on">Posted 22 hours ago</span> /
<span class="posted-in">News, Important</span>
However when the page is loaded in the browser the outer div is no longer there.
Try to do php cancatenation as:
<?php echo '<div class="entry-meta">'.theme_post_meta().'</div>'; ?>
Related
Is this possible? I have not seen this kind of codes. I really wanted to implement this but i was not able to search for it or I do not know how this kind of execution is called.
On a php page I have this elements of divs.
elements.php
<div id="countries">
<p>Malaysia</p>
<p>India</p>
</div>
<div id="cities">
<h2>sihgn</h2>
<p>sighn city</p>
</div>
<div id="street">
<h2>nowhere</h2>
<p>somewhere</p>
</div>
and on the showcountryonly.php which displays the specific div only.
<?php include (elements.php)?> ???? echo div #countries
on the showcitiiesonly.php which displays the city only.
<?php include (elements.php)?> ???? echo div #cities
on the showstreetonly.php which displays the street div only.
<?php include (elements.php)?> ???? echo div #street
The reason I want to implement this is I want to only edit one page for all of my includes.
Thank you.
You can define a variable for each div in elements.php:
$countries = '<div id="countries">
<p>Malaysia</p>
<p>India</p>
</div>';
$cities = '<div id="cities">
<h2>sihgn</h2>
<p>sighn city</p>
</div>';
$streets = '<div id="street">
<h2>nowhere</h2>
<p>somewhere</p>
</div>';
After including the elements file, you can just echo the needed variable:
<?php
include (elements.php);
echo $countries; // $cities or $streets
?>
Hope this helps.
I'm making a website where users can post stories etc and they get put into the MySQL database and the front page pulls the top-rated stories from the database and fills in the HTML template I made to display.
So I pull the top rated post and put it inside the article tags that I've made inside my HTML. The question is when it displays it displays outside of the box. Like so
The actual display is supposed to look like this
How do I format the PHP code, Or is there some better way to go about doing this?
<article class="post featured">
<header class="major">
<span class="date">April 25, 2017</span>
<h2>
And this is a<br />massive headline
</h2>
<?php echo '<p>' . htmlspecialchars($row['post'], ENT_QUOTES, 'UTF-8') . '</p>'; ?>
</header>
<img src="images/pic01.jpg" alt="" />
<ul class="actions special">
<li>Full Story</li>
</ul>
<span class="tags badge-pill badge-primary">Otero</span>
<span class="tags badge-pill badge-info">SCR</span>
<span class="tags badge-pill badge-success">Class of '22'</span>
<span class="tags badge-pill badge-danger">Male</span>
</article>
EDIT: Here is the HTML spot I'm talking about
Ok, It`s easy to solve. First your string has only one word (because doesn´t have spaces) an second, when you have a paragraph, the tag that wrap content has an autoalignement.
Maybe you can try adding some css rules for your parent div?
You may check this : https://stackoverflow.com/a/3367759/8186765
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
I'm working on a simple project which has a requirement to show a particular block of html by passing an div id to that url.
I have tried so many solutions, but none of them worked for me.
Here is my code.
<div class="row">
<a onclick="redirect_tooltip();">
<i class="fa fa-question-circle" aria-hidden="true"></i>
</a>
</div>
Whenever I click the icon it calls a Javascript function, through that function I tried to pass a url with another page division id
function redirect_tooltip()
{
var source_type = $("#_src_type").val();
if(source_type == "source")
{
window.location.replace(base_url+'/help/tooltip#rtmp_4');
//I have already difined the base url
}
}
My html code:
<div id="rtmp_4">
<h4>Some Title</h4>
<h5> <?php echo trim($tooltip_rtmp_server[1]);?></h5>
<p> <?php echo trim($tooltip_rtmp_server[3]);?> </p>
<h5> <?php echo trim($tooltip_rtmp_stream_name[1]);?></h5>
<p> <?php echo trim($tooltip_rtmp_stream_name[3]);?> </p>
</div>
I need to display only the rtmp block whenever the url executes. Please give me a suggestions like where I am doing the mistake.
In hiddenModalContent div is it possible to display the database value as once thickbox is opening it just showing nothing
<?php
foreach($this->list_details as $key=>$details)
{?>
<div class="sc_content_subheading"><? echo $this->escape($details['list_name'])?></div>
<div id="hiddenModalContent" style="display:none;">
<span class="content_subheading">List name </span><? echo $details['list_name'];?><br/>
</div>
<?php }?>
It seems all you are only outputting the list name. What else in the array would you like to show?