• Resolved Augustin

    (@augustin)


    Hi everybody,

    My problem is the following : I would like to modify my forum pages so that the page title doesn’t appear on them. They all begin with “https://www.litteratureaudio.com/index.php/forums/”. Of course, I don’t want to make disappear the titles on the other pages I’ve got on my website.

    That’s why I’ve tried to modify the page.php template, but without success. I think it’s because you can’t use the <?php … ?> syntax inside a <?php … ?> loop.

    Could you help me find a solution ? Here is the code’s part of the page.php template in question :

    <?php
    if($_SERVER['REQUEST_URI'] == "/index.php/notre-association/" OR $_SERVER['REQUEST_URI'] == "/index.php/nous-aider/" OR $_SERVER['REQUEST_URI'] == "/index.php/nous-contacter/" OR $_SERVER['REQUEST_URI'] == "/index.php/livre-dor/" OR $_SERVER['REQUEST_URI'] == "/index.php/notre-bibliotheque-de-livres-audio-gratuits/" OR $_SERVER['REQUEST_URI'] == "/index.php/classement-de-nos-livres-audio-gratuits-par-notes/" OR $_SERVER['REQUEST_URI'] == "/index.php/classement-de-nos-livres-audio-gratuits-par-votes/" OR $_SERVER['REQUEST_URI'] == "/index.php/livres-audio-gratuits-sur-internet/" OR $_SERVER['REQUEST_URI'] == "/index.php/ebooks-gratuits-sur-internet/" OR $_SERVER['REQUEST_URI'] == "/index.php/referencement/"){
    echo "<div id='content'>"; }
    else{
    echo "<div id='content2'>";
    }
    ?>
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <div class="entry">
        <h3 class="entrytitle" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark">
          <?php the_title(); ?>
          </a> </h3>
        <div class="entrymeta-single">
          <?php
    			edit_post_link(__('<strong> &Eacute;diter</strong>'));?>
        </div>

    What I would like to do is to insert all this code in the “if” condition and leave the “else” condition blank.

    Thanks for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • bpartch

    (@bpartch)

    Hello

    Is the top part the code you made to try to do this? If so, scrap it and go with this instead:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- start entry -->
    <div class="entry">
    
    <?php if (!is_page('forums')) { ?>
    <h3 class="entrytitle" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <?php } ?>
    
    <div class="entrymeta-single"><?php edit_post_link(__('<strong>&Eacute;diter</strong>')) ;?></div>
    
    </div>
    <!-- end entry -->

    If the top part of the code was for something else, add it back and still use this. If it does not work, post again.:)

    Thread Starter Augustin

    (@augustin)

    Thanks a lot ! That’s exactly the function I was looking for: <?php if (!is_page(‘forums’)) { ?> … <?php } ?>

    (But I’m not so familiar with php coding so didn’t know how to put it).

    It now works perfectly (and also makes lighter some other parts of my code). Thanks again.

    I hope this message can help other people who have the same problem.

    Thank you too… this is also what I have been hunting for!

    Peter

    Hi,

    I think this advise is useful, and sort of resolves an issue I’m having, but mine affects hiding the page title on the home page.

    The code above doesn’t seem to work. I tried substituting the word ‘forum’ in the code above with ‘home’ (the title of my home page) but it doesn’t work. I guess this is because when viewing the home page it doesn’t appear in the address bar as [site url]/home/ but as [site url].

    How would I go about using this coding solution to resolve this issue?

    Thanks in advance,
    Tony.

    Just adding some info that helped me out with something similar.

    The is_page() function checks for page ID’s too, so you could exclude the title like above like this (my page ID is 3):

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- start entry -->
    <div class="entry">
    
    <?php if (!is_page(3)) { ?>
    <h3 class="entrytitle" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <?php } ?>
    
    <div class="entrymeta-single"><?php edit_post_link(__('<strong>&Eacute;diter</strong>')) ;?></div>
    
    </div>
    <!-- end entry -->

    Fluvius: you can use is_home() instead of is_page()

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How not to show the page title on definite pages ?’ is closed to new replies.