WordPress.org

Forums

Excluding a plugin from a certain page (10 posts)

  1. rauuul1
    Member
    Posted 6 years ago #

    Hi,

    I added a little ajax like - dislike plugin to my site and it's working nicely. The problem is, i want the like - dislike to be shown only on posts, not on every page, like here: http://whatdidyoudo.org/?page_id=2

    I can't use Widget Logic plugin, cause the ajax widget isn't in the sidebar. Is there a php or css code that I can add to page.php or somewhere so it would exclude the widget from certain pages?

    Thanks

  2. crayoncrisis
    Member
    Posted 6 years ago #

    If you have a single.php file, WP will use that to display posts. So you could add the code there. Stepping into templates

  3. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    Try deeactivating the plugin to keep it from loading all the time, and then using this in header.php to show the like/dislike only on home:

    <?php } if (is_page('home')) { ?><script type='text/javascript' src='http://whatdidyoudo.org//wp-content/plugins/visitor-likedislike-post-rating/js/jquery-1.3.2.min.js?ver=1.3.2'></script><?php } ?>

    jQuery should load OK for the rest of the scripts in your theme, but try it.

    You also seem to have a trailing slash on your site URL in ypur settings, and that is puting a double slash on your include URLs; look in page source to see what I mean.

  4. rauuul1
    Member
    Posted 6 years ago #

    Thank you for your reply, I deactivated the plugin and added the code into header.php, but I got this error:

    Parse error: syntax error, unexpected '}' in /home/a8787359/public_html/wp-content/themes/p2/header.php on line 13

    And how can I get rid of the trailing slash?

    Thanks

  5. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    Sorry, my mistake on the php; should be:

    <?php if (is_front_page()); ?><script type='text/javascript' src='http://whatdidyoudo.org//wp-content/plugins/visitor-likedislike-post-rating/js/jquery-1.3.2.min.js?ver=1.3.2'></script><?php;?>

    Look in Settings/General to see if you have a trailing slash on your blog URL

  6. rauuul1
    Member
    Posted 6 years ago #

    Another error:

    Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/a8787359/public_html/wp-content/themes/p2/header.php on line 11

  7. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    Sorry again. It's too early in the morning! I corrected the code directly above and tested it again.

  8. rauuul1
    Member
    Posted 6 years ago #

    Now it doesn't give any errors, but it also wont show up the like/dislike links. I have to learn php..

  9. Mark Ratledge
    Forum Moderator
    Posted 6 years ago #

    I don't see the like/dislike plugin loading in page source; sure that code is in header.php above the </head> tag?

    I use that technique for some plugins, but it also may depend on how that plugin hooks in to WP, too.

  10. rauuul1
    Member
    Posted 6 years ago #

    Yes, I took it down for a minute and added it again now, still no change.

Topic Closed

This topic has been closed to new replies.

About this Topic