Forums

Trying 2 add plugin shortcode in footer on 1 page only (3 posts)

  1. klogan2
    Member
    Posted 1 year ago #

    Hey all,
    Trying to add a shortcode for FB comments in the footer on 1 page only, i.e. the "Home" page.
    I can add the shortcode no problem:echo do_shortcode('[fbcomments]');
    But I want to isolate this to the home page footer.
    I've been mucking around with various CSS approaches to no avail (like trying to hide the DIV, class, etc.), so now I am trying a PHP approach, but the only prob with that is I don't know PHP. But here is what I am "thinking" is the overall idea:

    <div id="facebookComments" class="facebookComments2">
    	<?php
    	if ( $thePostID = 12 )
    	echo do_shortcode('[fbcomments]');
    	?>
    </div>

    Any suggestions/ideas? greatly appreciated. Am I an idiot for even attempting this? (Don't worry, U won't hurt my feelings).
    Cheers,
    Kevin

  2. klogan2
    Member
    Posted 1 year ago #

    Figured it out,, yea :) Sometimes I just don't know what to google for, but I woke up this morning, and it popped into my brain, I want to do a conditional statement. SO (maybe not prettiest code, but works):

    <?php if ( is_page('12') ) {
          echo do_shortcode('[fbcomments]');
          } else {
          }	 ?>

    where the #12 is, is the page ID. It can also be the page title, slug, etc... Turns out there are a bunch of possibilities
    I came across this article that explained it well & simply enough that I was able to accomplish what I wanted, FB comments in the footer, on the home page only!!! :)

  3. klogan2
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic