Currently in the PHP file it has:
<?php if($myfooter_text){?>
<?php echo of_get_option('footer_text'); ?>
<?php } else { ?>
something else here
<?php } ?>
What I would like is for it to insert the footer text it finds using $myfooter_text but also add a link to the end of whatever has been pre filled in the footer text. I tried to use concatenation with the following:
<?php echo of_get_option('footer_text') . 'mylink; ?>
However this still just shows the predefined footer text and not the additional content. Is there a way to do this? I'm aware it could be added in the footer area of the dashboard but this isnt what i want to do.
Try it like this:
<?php echo of_get_option('footer_text'); ?> mylink
You can concatenate them as well like this or do it your way and be sure you close all the quotes:
<?php echo of_get_option('footer_text') . 'mylink'; ?>
Related
I have a wordpress function that displays adverts every so often. When are not shown essentially I would prefer to the div to display:none;
I can not seem to figure out the correct PHP function in order for the div not to display when a advert is uploaded.
<div class="advert" <?php if(!empty($_GET['details'])) {echo "style='display: none'";} ?>></div>
Why not completely not echo "advert" element?
if ( !empty($_GET['details']) ){
echo '<div class="advert">add text</div>';
}
if you really want to just hide, you can assign hide class
<div class="advert <?php echo ( empty($_GET['details'])? 'hide' : '' );">add text</div>
then you would need to add "hide" class with display:none in your style.css
Above is shorthand/ternary if/else statement used, its great if you need output some string.
And, please don't output/trust any user input i.e. $_GET['details'] 'as is' anywhere without escaping it, for security reasons.
Wordpress have plenty easy-to-use escape functions, like esc_attr() and esc_html().
This should do it for you
<?php
$advert_display_string = "";
if (!isset($_GET['details'])) {
$advert_display_string = "style='display: none'";
}
?>
<div class="advert" <?php echo $advert_display_string ; ?> ></div>`
but having said that, instead of displaying it and then hiding it with css, you could just choose only to display it if you need it there, like below
<?php
if (isset($_GET['details'])) {
?>
<div class="advert"></div>
<?
}
?>
How can I use the HTML <code> element to output a block of PHP code, without the page running that PHP code? Eg;
<pre><code>
<?php
// Some super duper PHP code
?>
</code></pre>
I'm creating an API docs page, which features snippets of PHP that anyone wishing to use the API can use as examples, but anything wrapped in <?php> tags runs as an actual PHP function
Use <?php and ?>.
The HTML entities will show up as PHP opening and closing tags when the page is rendered, but PHP will obviously not see them. But you have to html-escape your code anyways, otherwise contained HTML-tags will be rendered. So there should be
<?php echo 'Hello, World.<br>'; ?>
Another way would be to have a string specified by a nowdoc and then output html-escaped (demo):
<?php
$code = <<<'EOC'
<?php
echo 'Hello, World.<br>';
// ...your code here...
?>
EOC;
echo htmlentities($code);
?>
Have look for different approaches at How do I display PHP code in HTML?.
Do this via PHP like so:
<?php
$code = '<?php
echo "Hello, World!";
?>';
echo '<code>' . htmlspecialchars($code) . '</code>';
?>
try something like this:
<?php echo '<?php'; ?>
This may help you.........
######################################################################
echo "<h2><br>Source Code of ".basename((string)__FILE__) . "</h2><hr>";
show_source(__FILE__);
echo "<hr>";
echo "<h2>Output of ".basename((string)__FILE__) . "<hr></h2>";
#######################################################################
I had to convert the less-than and greater-than to their HTML name.
<pre><code><?php echo
"<!--
This is the church title to be used in the heading of the web-pages.
Author: John Fischer III of Written For Christ in 2018
Updated:
-->
<?php echo 'Our Little Church:'; ?>" ?>
</code></pre>
I want this to work, it doesn't currently, so, if its possible, what do I need to change:
<?php echo $page_title_LEADER; ?>
In the config file I have
define('ENGLAND_LEADER', 'Bob Smith:');
define('SPAIN_LEADER', 'Stan Smith:');
which when I use:
<?php echo ENGLAND_LEADER; ?>
works fine as you would expect, what I'm trying to do is use the page title to auto fill the COUNTRY name part of COUNTRY_LEADER, so I don't have to manually change the name of the country each time.
NB I do have the $page_title set in the page
You can use the constant function for this
<?php echo constant($page_title . '_LEADER') ?>
I'm displaying a gallery on my wordpress site using the following code:
<?php echo do_shortcode('[satellite gallery=2 auto=off caption=off thumbs=on]'); ?>
Now I've added a custom post value/field called 'guitLink' where I can add the gallery number which I want to then use in the above shortcode, so something like this:
<?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). 'auto=off caption=off thumbs=on]'); ?>
Any ideas how to achieve this?
Use:
<?php $guitLink = get_post_custom_values('guitLink');
echo do_shortcode('[satellite gallery=' .$guitLink[0]. ' auto=off caption=off thumbs=on]'); ?>
Instead of
<?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). ' auto=off caption=off thumbs=on]'); ?>
this is the code where it load my dynamic menu
<?php echo $this->dynamic_menu->build_menu('1'); ?>
this is the code for my language type
<?php echo lanchor($uri, lang('menuenglish')); ?>
here i wanto to add like this
<?php echo $this->"<?php echo lanchor($uri, lang('menuenglish')); ?>"->build_menu('1'); ?>
i know the uper code is wrong but for makeing it clear..
instead of the dynamic_menu i wanto to echo from my language varaiables
one of my language variable inside the dymanic menu
regards
Just do this :
<?php
$menu = lanchor($uri, lang('menuenglish'));
echo $this->{(string) $menu}->build_menu('1');
?>
But if you search for this in Google, you will be able to find the answer.