Ravin
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Adding Javascript data table into my wordpress site@bob is right.
I assume you were just asking how to queue or echo the script from php/wordpress.
In plain html, to get the browser to read your javascript, you either
1. paste a script tag that points to your javascript file.<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
2. Or directly paste your javascript code in the html script tag.
<script type="text/javascript"> jQuery('#table-id').DataTable({}); </script>
There are other ways, but i don’t want to get into it, its not important in your case.
In php/wordpress, it is the same. The difference is you are letting wordpress to place your script source, or echoing javascript using php.
When you install multiple plugins, and install some theme, sometimes theme and plugins can load the same javascript library, e.g. certain plugins load their own jQuery versions, which can cause conflict to other javascript functions and maybe wordpress itself, you can register multiple version of jQuery via wordpress register/enqueue and load the appropriate version based on the logic of your site or application, this avoid unnecessary conflicts with other libraries and javascripts. This applies to all javascript libraries and functions not just jQuery.The example i pasted previously, does the same thing as pasting into html but instead uses php to create the script tags in html.
1. Place script tags and source into html via php.<?php add_action( 'wp_footer', function() { ?> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.11/js/jquery.dataTables.min.js"></script> <script src="src="//cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.js""></script> <script type="text/javascript"> jQuery('#table-id').DataTable({}); </script> <?php }, 9999);
2. Register/enqueue scripts through wordpress register and enqueue function.
<?php function wp_add_scripts() { // name_of_script_you_want_to_give, path_of_script_template_directory, required_js_scripts wp_register_script('my_script', get_template_directory_uri() . '/js/my_script.js', array('jquery')); wp_enqueue_script('my_script'); } add_action( 'wp_enqueue_scripts', 'wp_add_scripts' );
If you need to load the script on a specific page or post. you need to add a condition that check for post type, id or slug, or anything which suits your situation.
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?WordPress is suppose to generate the .htacess when you save permalinks. It could be permission issues.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Forum: Localhost Installs
In reply to: Using MAMP and trying to set-up WordPress.@guymonahan, your wordpress will be basically in any folder that your Apache server will treat as root document, in your case is htdocs.
You can name your database anything you want, just make sure your are not overriding an existing database.Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?@notalentgeek. This is strange. It could be your htaccess, if you are hosting on a server, try asking your hosting provider if they can assist you with this problem. I’m running out of checklist.
1. wp-config settings is right [Check]
2. database all tables working [Check]
3. blog url is set [Check]
4. permalink refreshed [Check]
5. plugins disabled [Check]
6. Changed template / Remove code from template [Check]
7. .htacess misconfiguredForum: Localhost Installs
In reply to: MAMP Installation: Using a pre-existing WordPress site?Localhost is a generic name to refer to the current machine you are using, e.g your server or your laptop/desktop.
Database is the place wordpress uses to store all your information in wordpress
Server is the machine that hosts your wordpress site on the internet.@alxm000 You might want to refer to your hosting provider on this, or find a developer that can help you out. They can provide you with more information on how to access your wordpress files.
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?@notalentgeek, if you can’t access wp-admin. disable plugin by renaming the folder /wp-content/plugins to something else like /wp-content/plugins_turn_off
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?@notalentgeek, do you have a previous working copy of your wordpress database. Try loading that and see.
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?@notalentgeek, delete your browser cookie.
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?@notalentgeek, You could try this, disable plugins. Refresh the permalinks.
Forum: Localhost Installs
In reply to: Using MAMP and trying to set-up WordPress.Hello guymonahan,
Make sure you have created the mysql database, then proceed with wordpress installation. You can see the guide here. https://codex.www.ads-software.com/Installing_WordPress#Famous_5-Minute_Install
Forum: Fixing WordPress
In reply to: WordPress website redirects to installation page. What should I do?Hello notalentgeek,
Remove the code, see if it works. Otherwise, Make sure your wp-config exist, and the db host setting is correct.
Forum: Fixing WordPress
In reply to: Adding Javascript data table into my wordpress siteYes. functions.php
Forum: Fixing WordPress
In reply to: Adding Javascript data table into my wordpress siteYou could add it into functions.php
<?php function wp_add_scripts() { // get $post global $post; if( $post->post_name == "the_page_slug" ) { // name_of_script_you_want_to_give, path_of_script_template_directory, required_js_scripts wp_register_script('my_script', get_template_directory_uri() . '/js/my_script.js', array('jquery')); wp_enqueue_script('my_script'); } } add_action( 'wp_enqueue_scripts', 'wp_add_scripts' ); ?>
Forum: Fixing WordPress
In reply to: Adding Javascript data table into my wordpress siteYou need to enqueue your javascript, so wordpress will load it.
Link:
https://codex.www.ads-software.com/Plugin_API/Action_Reference/wp_enqueue_scriptsAnother option is add it to wp_footer hooks.
Link: https://codex.www.ads-software.com/Function_Reference/wp_footerExample:
<?php add_action( 'wp_footer', function() { ?> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.11/js/jquery.dataTables.min.js"></script> <script src="src="//cdn.datatables.net/plug-ins/a5734b29083/integration/bootstrap/3/dataTables.bootstrap.js""></script> <script type="text/javascript"> jQuery('#table-id').DataTable({}); </script> <?php }, 9999);
Hope this helps.
Forum: Fixing WordPress
In reply to: Adding Javascript data table into my wordpress site@dlungaro, first you need to add the javascript to the template to load it. Maybe you want to elaborate on what you have done so far. Otherwise this could get very long.