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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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