• 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

Where to put this .js snippet

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 › Where to put this .js snippet

This topic is: not resolved
  • This topic has 4 replies, 2 voices, and was last updated 8 years ago by tussle.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • December 29, 2014 at 1:39 pm #135582
    tussle
    Member

    Hi
    I found a simple snippet to add line numbers to the left side of the text area in WP admin. Comes in handy.

    I know how to upload the .css and .js file, but 2 questions:
    1. into what directory do the files get uploaded
    2. where do I place the code as mentioned in this step:

    Installation: Copy the files to your web server and insert the .js and .css file and you are good to go. Requires JQuery 1.3+

    The piece of script provided was this:

    <script>
    $(function() {

    // Target all classed with ".lined"
    $(".lined").linedtextarea(
    {selectedLine: 1}
    );

    // Target a single one
    $("#mytextarea").linedtextarea();

    });
    </script>

    Thanks !
    Does this go in the admin file called post at the top?
    Where does the .css file go?
    Don't want to break my site.

    http://alan.blog-city.com/jquerylinedtextarea.htm
    December 29, 2014 at 9:37 pm #135620
    Ren Ventura
    Member

    I'd recommend placing the files in a custom plugin because this is likely something you'll want to maintain even if you switch themes. Here's a link to a post I wrote on how to do it.

    http://www.engagewp.com/adding-wordpress-functions-via-plugin/

    You can create whatever directories you want or just put everything in the root. The important thing is that you make sure your paths are correct when you include/enqueue any files.


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    December 30, 2014 at 12:08 pm #135679
    tussle
    Member

    Thanks Ren.

    So I just copy the script above into a .php file as you stated on your post, then upload the 2 files making sure they are referenced correctly in the script (per your post), then upload the .js and .css file? How do I activate the code then?

    January 5, 2015 at 1:43 am #136089
    Ren Ventura
    Member

    It looks like you'll need to do the following:

    1. Download the files and include them in the plugin;
    2. Create a new js file to instantiate (create a new instance of) the script
    3. Enqueue the scripts and stylesheet in your main plugin file

    From there, you would activate the plugin like any other plugin (upload the zip file via the plugin installer). Just make sure to include the proper heading.

    Hopefully this helps. If you're not comfortable with doing all that, you can hire a developer or do some research on integrating JS plugins with WordPress so you can see other examples on how it's done.


    Web & Software Developer & Blogger | RenVentura.com | Follow Me on Twitter @CLE_Ren

    September 6, 2015 at 3:19 pm #164786
    tussle
    Member

    I thought I said a 'thank you' for this code - looks like the post didn't get published at that time, so thanks for the input. Appreciated.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 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