This is the code I tried but unfortunately does not work
<?php if(get_the_ID()==22) : ?>
<p class="dg-design"> website by dgdesign </p></p>
elseif(ICL_LANGUAGE_CODE=='es'){
<p class="dg-design"> websadsasite by dgdessadsadaign </p></p>
}
<?php endif; ?>
Can you tell me what is wrong please?
At the moment when I run the site does not change anything
I use a wordpress theme.
Can you give an example to show me how can I solve this problem?
Thanks in advance!
<?php if(is_page(22)){?>
<?php if(ICL_LANGUAGE_CODE=='en'){?>
<p class="dg-design"> website by
dgdesign
</p>
<?php }elseif(ICL_LANGUAGE_CODE=='es'){?>
<p class="dg-design"> websadsasite by
dgdessadsadaign </p>
<?php }?>
<?php }?>
Related
I'm trying to output content from an Advanced Custom Fields (ACF) in my wordpress theme. At the moment though, all I'm getting is the plain text content from the ACF inside double quotation marks, not inside the div and h1 tags.
The code is copied from another theme I made where it worked, which makes me think something is interfering with it somewhere?
<?php $process_title = the_sub_field('process_title'); ?>
<?php if(!empty($process_title)) : ?>
<div class="process-title">
<h1 class="process-heading">
<?php echo $process_title; ?>
</h1>
</div>
<?php endif; ?>
Thanks to #M.Eriksson, the correct code should be:
<?php $process_title = get_sub_field('process_title'); ?>
<?php if(!empty($process_title)) : ?>
<div class="process-title">
<h1 class="process-heading">
<?php echo $process_title; ?>
</h1>
</div>
<?php endif; ?>
i'm creating a new blog in wordpress
and i got a problem with index.php file
the button is not showing and i tried a lot and nothing change
this is the code in index.php
<div class="block n-p">
<?php previous_posts_link(); ?>
||
<?php next_posts_link(); ?>
</div>
<!--End block-->
any Advice please?
and thank you for the Support.
I think it should be
<?php previous_post(); ?> <?php next_post(); ?>
without the "_link"
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 have a MySQL database storing some basic user info, so: name, email, and two phone numbers. I want to make a page with dynamic php text showing the users info, but in the database only one phone number is required. On the page I have:
<p id="first"> Some non-dynamic text </p>
<p> <?php echo $row_rsCustomer['first_name']; ?> </p>
<p> <?php echo $row_rsCustomer['email']; ?> </p>
<p> <?php echo $row_rsCustomer['phone_one']; ?> </p>
<p id="phonetwo"> <?php echo $row_rsCustomer['phone_two']; ?> </p>
<p id="second"> Some non-dynamic text </p>
I dont want the #second to be pushed down if the #phonetwo is empty. I was thinking of using some javascript like this:
if( #phonetwo.innerhtml == ""){
#phonetwo.style.display="none";
But I was wondering if there's a way to do this using php? The javascript solution will work I suppose, but I'm pretty sure I've seen somewhere a more "correct" way to do this, I just don't remember what it was nor can I find it anywhere.
Just wrap the paragraph in a conditional
<?php if(isset($row_rsCustomer['phone_two']) && $row_rsCustomer['phone_two']):?>
<p id="phonetwo"> <?php echo $row_rsCustomer['phone_two']; ?> </p>
<?php endif?>
<?php if (!empty($row_rsCustomer['phone_two'])) { ?>
<p id="phonetwo"><?php echo $row_rsCustomer['phone_two'] ?></p>
<?php } ?>
Just follow this pattern anytime you need to hide HTML from PHP:
<? if (your condition) { ?>
Html
<? } ?>
It is much better than doing it in JS since it does't send any data to the browser.
First check is it empty or not
<?php if(!empty($row_rsCustomer['phone_two'])) { ?>
<p id="phonetwo"> <?php echo $row_rsCustomer['phone_two']; ?> </p>
<?php } ?>
check if $row_rsCustomer['phone_two'] is not empty and then display your <p> :
<?php if (isset($row_rsCustomer['phone_two'])) { ?>
<p id="phonetwo"><?php echo $row_rsCustomer['phone_two'] ?></p>
<?php } ?>
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.