Jump to content

If Statement


atmmultimedia

Recommended Posts

Hello everyone,

 

Firstly, I want to say this is the best forum I've seen so far.

 

I have a basic knowledge of PHP. I can get by with includes.

 

I am modifying a WordPress website for a client.

 

The client wants a video player displayed in the website, which is fine. There is an include there for the video player.

 

WordPress is made up of several PHP files.

 

In the header file: I've placed this code:

 

<?php if ( is_page('7') ) { ?>

 

 

  <?php include('videoplayer.php'); ?>

 

 

<?php } else { ?>

 

<?php } ?>

 

 

Which means on page 7 of the wordpress site displayed the content of the video player. In the video player.php file there is a title and breadcrumb.

 

In the image attached you can see I have a duplicate title and brumbcrumb, the title and breadcrumb below the video player needs to be removed. I am curious how to apply an if statment to this.

 

Here is the code I'll need to change to apply the if statement.

 

Any help will be greatly appreictated.

 

 

<?php

// the title

if (strpos(get_the_title($post->ID), '//')) {

$thisTitle = '<strong>' . str_replace('//', '</strong>  //  ', get_the_title($post->ID));

}else {

$thisTitle = '<strong>'. get_the_title($post->ID) .'</strong>';

}

?>

<!-- Title / Page Headline -->

<div class="full-page">

<h1 class="headline"><?php echo $thisTitle; ?></h1>

</div>

 

<div class="hr"></div>

 

<!-- Breadcrumbs -->

<div class="full-page">

<p class="breadcrumbs">

<?php show_breadcrumbs(); ?>

</p>

</div>

 

<!-- End of Content -->

<div class="clear"></div>

 

 

What I am trying to do is to place if statement that if page is = 7 appears I'd like no post title and no breadcrumbs please.

 

Many many thanks

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/203191-if-statement/
Share on other sites

This could be done a few ways. You could do it with CSS, which is what I would do because it has the least modifications to the code.

 

Pardon my pseudo-code.

if ( is_page('7') ) {
echo '<style type="text/css">.breadcrumbs{display:none !important;} .headline{display:none !important;}';
}

Link to comment
https://forums.phpfreaks.com/topic/203191-if-statement/#findComment-1064595
Share on other sites

Hi I've tried that,

 

And it appears not to do anything unless. I've placed the code in the wrong place.

 

<?php

 

if ( is_page('7') ) {

echo '<style type="text/css">.breadcrumbs{display:none !important;} .headline{display:none !important;}';

}

// the title

if (strpos(get_the_title($post->ID), '//')) {

$thisTitle = '<strong>' . str_replace('//', '</strong>  //  ', get_the_title($post->ID));

}else {

$thisTitle = '<strong>'. get_the_title($post->ID) .'</strong>';

}

?>

<!-- Title / Page Headline -->

<div class="full-page">

<h1 class="headline"><?php echo $thisTitle; ?></h1>

</div>

 

<div class="hr"></div>

 

<!-- Breadcrumbs -->

<div class="full-page">

<p class="breadcrumbs">

<?php show_breadcrumbs(); ?>

</p>

</div>

Link to comment
https://forums.phpfreaks.com/topic/203191-if-statement/#findComment-1064596
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.