1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

NEED help with PHP - Adding to Thesis Single Post

Discussion in 'General Programming Chat' started by Cash1t, Sep 20, 2012.

  1. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    I have tried and tried. 2 days now. So now I am asking for a little help. I have a PHP code to call a content locker that I want to add to all single posts only. I have tried several hooks with no success. I also tried adding a SINGLE POST template but could not call the actual post content. Any help would be appreciated.
     
  2. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
    I have tried reading your mind and hacking your server but I cannot.

    Any help would be appreciated.
     
    • Thanks Thanks x 1
  3. seo-dude

    seo-dude BANNED BANNED

    Joined:
    Sep 4, 2012
    Messages:
    147
    Likes Received:
    56
    Try to explain what have you done, what did you try and what's the result/error etc for people to help you... no one really understands what you need...
     
  4. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    I am attempting to use CPA GATELOCK on a Wordpress site using THESIS THEME. I uploaded the files into the wp-content folder as directed. Since THESIS does not have a simple SINGLE POST TEMPLATE to edit and add the code to call the locker, I used a HOOK I found:
    function do_in_post_only() { if (is_single()) { /don't show on the home page/ ?>
    ERROR RECEIVED:
    Parse error: syntax error, unexpected '/' in .....URL INFO.....................custom_functions.php on line 5
    System deletes when I post URL info in msg
     
    Last edited: Sep 20, 2012
  5. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
    Comments using // are single, whole line comments.
    Comments using /* and */ are variable length and line comments.

    If you meant for it to be a comment (double slash instead of single), you would be chopping off everything from the first // including the ?> which would still product an error.
     
  6. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    OK I took ALL of the comments out. I still get ERROR: Parse error: syntax error, unexpected '}' in URL INFO.....wp-content/themes/thesis_18b/custom/custom_functions.php on line 11 THIS IS THE LINE:
    PHP CODE OPEN - } } add_action('thesis_hook_after_post','do_in_post_only');
     
  7. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    I changed it [SEE ATTACHED]. Error msg went away but content locker doesn't come up.
     
    Last edited: Sep 21, 2012
  8. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
    Put code between [ code ] [ /code ] tags. Minus the spaces.
     
  9. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    Code:
    function do_in_post_only() { if (is_single())   ?>    add_action('thesis_hook_after_post','do_in_post_only');  
     
  10. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    SITUATION RESOLVED. While I would prefer to learn the proper HOOKS and PHP coding, I did find a solution. It's a WORDPRESS PLUGIN called "Allow PHP In Posts." Used the shortcodes and inserted the PHP and Voila!! CONTENT LOCKED! I appreciate Zapdos and seo_dude for responding to my post. Thanks
     
  11. Zapdos

    Zapdos Power Member

    Joined:
    Oct 22, 2011
    Messages:
    597
    Likes Received:
    708
    Location:
    Eastern North Carolina
    Code:
    function do_in_post_only() 
    { 
    if (is_single()) 
    add_action('thesis_hook_after_post','do_in_post_only');
    } 
     ?>
    
    Probably what you wanted. You were missing the closing } bracket and the add action was out of the php delims.
     
    • Thanks Thanks x 1
  12. Cash1t

    Cash1t Registered Member

    Joined:
    May 27, 2009
    Messages:
    78
    Likes Received:
    36
    Thank you Zapdos, I really appreciate it.