• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to insert a code just after the content?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › How to insert a code just after the content?

This topic is: not resolved
  • This topic has 5 replies, 2 voices, and was last updated 8 years, 10 months ago by wparrow.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • January 31, 2015 at 6:18 am #139138
    wparrow
    Member

    Hello
    I am using News Pro theme, I installed a rating plugin and a view counter plugin and both auto display at the bottom of the single article. But I want insert my own Facebook code at the bottom of the article also but above these plugins.

    How can I do ? I tried with Genesis Simple Hooks but I unable to do as my want.

    Thanks for the help

    January 31, 2015 at 8:19 am #139161
    Genesis Developer
    Member

    Use the filter for the_content() function. Code will be like this:

    add_filter( 'the_content', 'add_fb_code' );
    function add_fb_code( $content ){
      $var = "ADD YOUR CODE HERE";
    
      // Now return the variable
      return $content . $var;
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    January 31, 2015 at 9:49 am #139177
    wparrow
    Member

    Thanks for your help, I added the facebook code and put all the code into file function.php and I got this error:

    Parse error: syntax error, unexpected 'fb' (T_STRING) in /home/xxx/public_html/xxx/wp-content/themes/news-pro/functions.php on line 270

    Here is the facebook code:

    <div class="fb-like" data-href="https://www.facebook.com/xxx.net" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>

    I have added this code to function.php

    //Add facebook code after content
    add_filter( 'the_content', 'add_fb_code' );
    function add_fb_code( $content ){
      $var = "<div class="fb-like" data-href="https://www.facebook.com/tvvn.net" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>";
    
      // Now return the variable
      return $content . $var;
    }
    January 31, 2015 at 9:59 am #139188
    wparrow
    Member

    I have tested your code without error but the facebook button is still display after these plugins

    January 31, 2015 at 9:59 am #139189
    Genesis Developer
    Member

    try this

    //Add facebook code after content
    add_filter( 'the_content', 'add_fb_code' );
    function add_fb_code( $content ){
      $var = '<div class="fb-like" data-href="https://www.facebook.com/tvvn.net" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>';
    
      // Now return the variable
      return $content . $var;
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    January 31, 2015 at 10:14 am #139192
    wparrow
    Member

    It's still display after two plugins voting and counting. I want it is number 1 position after the content

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble