Forum Replies Created

Viewing 15 replies - 1 through 15 (of 26 total)
  • Thread Starter Burgejos000

    (@burgejos000)

    I dont think this file acts as a template. I mean, it kind of does, but not quite. I was able to make it act as a template file though so the page is set up through that file, however, I dont think this is the correct way to do it. I’ve had a few problems with trying to set up a child theme. Like changing files in the images folder and such.

    Thread Starter Burgejos000

    (@burgejos000)

    I can always toy around with it and try multiple methods. This is the first theme i’ve had to heavily hack. What are some methods that usually work?

    Thread Starter Burgejos000

    (@burgejos000)

    thanks for your help. I just created the wildcard sub domain, although I am not sure what if means when it says

    Make sure to point this at the same folder location where your wp-config.php file is located.

    under how to set it up via C-pannel.
    I have everything ready to go. I actually already have the network set up, I guess I did not create the subdomain’s correctly. Also, I do not need to create the sub domain name with my web host server, do i?

    Thread Starter Burgejos000

    (@burgejos000)

    Alright. I know that child themes work with their theme. Its been working so far. They dont support modifying their theme. So I was checking if anybody on here had an idea. I didnt see anything in the wordpress codex about it. I know that child themes will pull the theme stylesheet and main php files like functions.php header.php ect. but im not sure about the ones that arent normally modified

    Thread Starter Burgejos000

    (@burgejos000)

    App Themes.

    Thread Starter Burgejos000

    (@burgejos000)

    lol. its alright if you make a mistake, im learning a ton of information. and its actually a lot to process. i had to read through your post 3 or 4 times to soak it all in. You have no idea how big of a help this. the codex only tells you so much, and its not very helpful to those completely new to the subject.
    one question i have that may be a little off topic, but a question that im pondering is, when i use the wp_enqueue_scrip(‘file-name’), is there a reason the file extension isn’t being used? like i may have two files with the same name, but with different extensions. Obviously it would be a lot less confusing if i named each file differently, but just out of curiosity, why isn’t the file extension needed?
    Now back to the topic, I currently have two scrips in my plugin folder and i edited the header.php
    header.php snip it:

    </head>
    <body onload="changeTarget();" <?php body_class(); ?>>
    <div id="target">Text that bots see</div>
    <?php if ( !get_theme_mod( 'background_image', false) && !get_theme_mod( 'background_color', false) ) : ?>
    <div class="bg-gradient">
    <?php endif; ?>

    my-pluglin.php:

    <?php
    /*
    plugin details, licensing and such
    */
    ?>
    //I don't need to end and start a new php code, correct?
    <?php
    function my_scripts_function() {
    	wp_enqueue_script('my_javascript'); // .js assumed
    }
    add_action( 'wp_enqueue_scripts', 'my_scripts_function' );
    
    ?>

    my_javascript.js:

    function changeTarget() {
       var targetDiv = document.getElementById("target");
       targetDiv.innerHTML = "Only javascript users see this";
    }

    I believe this is all that i need at the moment, correct? also, the .js file should be put where?
    in this directory: plugins/my-plugin/
    or in this one: plugins/my-plugin/js
    I believe you told me to put it in a folder called js. (i tried it in both directories to see if that might be a problem)
    And off of that, yet another question. Would it matter if the .js file was in the same directory as the my-plugin.php or in its own folder?

    Thus, when the page loads, the javascript file is loaded as well, so the page knows what functions are defined, and any code not in a function is executed immediately.

    How does the header.php know where that script is located?
    If i might ask, what do the tags getElementByID and .innerHTML do?
    and lastly, about what you said here:

    One would typically put the wp_enqueue_script() call inside a conditional so it is loaded only when needed.

    If i only wanted it display on one or two pages, would i use something like:
    if(is_post’1557′)?
    and if so, how would that be set up? my guess is that it may look like:
    function my_scripts_function(if(is_post’1557′)) {
    wp_enqueue_script(‘my_javascript’); // .js assumed
    }
    or something like that, but while being new to this, im not sue if that is set correctly.

    Thread Starter Burgejos000

    (@burgejos000)

    I dont think i can thank him enough, i have learned so much from the questions he’s answered. i know many people will also learn a ton of info when googling anything somewhat related to this subject

    Thread Starter Burgejos000

    (@burgejos000)

    I thought about why it wouldnt run and i realized that the plugin-name.php did have an action hook that involved running when the header.php was ran. This is what i have for the code for the .php file:

    <?php
    function my_scripts_function() {
    	wp_enqueue_script('my_javascript'); // .js assumed
    }
    add_action( 'wp_head','wp_enqueue_scripts', 'my_scripts_function' );
    
    ?>

    I have the file header and license in the script as well. I didnt think there was a need to state it on here.
    Something seems off about how is put into the script.. I’m not sure what it is because i am new to all of this.
    The code:
    add_action( ‘wp_enqueue_scripts’, ‘my_scripts_function’ );
    is just saying, launch my javascript file, correct. But if ‘wp_enqueue_scripts’ is mentioned and ran in the ‘my_scripts_function’ actiction hook, is it needed to be ran again?
    and after that train of thought, wouldn’t it just need to be:

    <?php
    function my_scripts_function() {
    	wp_enqueue_script('my_javascript'); // .js assumed
    }
    add_action( 'wp_head', 'my_scripts_function' );
    
    ?>

    Isn’t that just saying, when wp_head is activated, activate the action hook ‘my_scripts_function’ and that will activate ‘wp_enqueue_script which will activate ‘my_javascript’?
    If my thought is correct, im not sure how header.php gets the information from my_javascript.js
    I tried just running:

    <?php
    function my_scripts_function() {
    	echo:'hello world';
    }
    add_action( 'wp_head', 'my_scripts_function' );
    
    ?>

    and the text ‘hello world’ was displayed on the page

    Thread Starter Burgejos000

    (@burgejos000)

    You have no idea how much of a help this is! Thank you so much!!
    I am having a bit of trouble activating the js script. The plugin is activated, the information was inserted into header.php. However, no part of the javascript is being seen. I have it enabled on my browser. With the basic knowledge I have of all of this, I would assume that everything would activate. Although, as the script within header.php runs, how would it know where the “changeTarget” is? I would assume if ithat was within the plugin-name.php, it would be able to locate the file and the script within the file, but would the header.php file be bale to do the same?

    Thread Starter Burgejos000

    (@burgejos000)

    Well. I am working on trying to write a basic php script. Nothing seems to be working for me. would you possibly be able to show me an example script? something basic that will display any text right before the content of the page using the ‘echo’ tag? once i have a basis with that, i can work from it using trial and error.
    When defining a function between the curly braces, you do not need to add a <?php…?> correct?
    also, when defining an action like this:
    function my_scripts_function()
    what is the between the brackets? Does anything go there or is just empty?

    Thread Starter Burgejos000

    (@burgejos000)

    Yeah. Im sorry. I didn’t realize that you were the same person. Lets move this over to this thread here

    Thread Starter Burgejos000

    (@burgejos000)

    I have been reading the Writing a plugin page in the codex. I understand it all until i get the coding part. I understand what an action hook is and how it works. I just don’t quite understand how it is written.
    This is probably basic, but what does the ‘$’ mean when writing in php with wordpress?

    On another related topic, so this bit of coding is basically defining my function?

    function my_action_hook() {
       global $wp_query;
       $post = $wp_query->get('queried_object');
       if(is_single() && $post->ID == 123) {
          //here is when i enter my code?
       }
    }

    Then the:
    add_action(‘wp_head’, ‘my_action_hook’);
    is basically saying when ‘wp_head’ is loaded, run ‘my_action_hook’ and there, my script will run?
    And off of that thought, my_action_hook may start to look like:
    wp_enqueue_script(//my javascript here)
    or
    init(//javascript file name)?
    I know that my java script will call another php upon a click and display the information back to the page.
    I am not quite understanding the last paragraph at all.
    And thank you so much for your help with all of this!

    Thread Starter Burgejos000

    (@burgejos000)

    Thanks for the reply. I am using the Graphene theme. What i am basicly doing is making a directory type plugin. Users will be able to search a database by choosing selecting information from a search bar via javascript. once they click submit, a php file will execute, collect the specific data from the database and send it back to the javascript to display the information on a page. Im using the same idea as this guy here: https://teamtutorials.com/web-development-tutorials/pulling-drop-down-values-from-a-database-using-javascript-and-php
    Just as an example, as i a a newbie to all of this, what would an example of an HTML comment look like?
    I know that i can use the echo tag to display information via php. Although it would be very useful information to know how to display java and html through php considering the plug in I am trying to make.
    I have explored many options with this. I originally wasn’t planning on making a plugin. I tried entering some code through the text field on the edit page, page. I tried creating a child theme, but whenever i copy and past the graphene theme, rename it graphene-child, and activate it, the layout is messed up and isnt as it should be. I’v created a custom template, but when doing that, i can’t display javascript, or execute another script without interrupting the loop.php So i just thought it would be easiest to create a plugin because it should be able to execute other scripts in the plugin folder without a problem, correct? I think this would be the most efficient way to do it, correct?
    But again, back to the main question for this reply, how would i add an HTML comment and allow it to be displayed in a php script?

    Thread Starter Burgejos000

    (@burgejos000)

    I am using the graphene theme. I’ve been told that it is very universal.
    So my plugin-name.php would start off like this:
    <?php
    wp_head…. if(is_post’1557′)
    ?>
    or something like that?

    I am very new to php. I have a specific HTML/java code that needs to execute other scripts based on the criteria entered in search field. Im not sure how to write it so that the HTML or JS script will be displayed in that specfic spot

    Thread Starter Burgejos000

    (@burgejos000)

    So i ended up just restoring a backup of the site. Back ups will always save your butt. But hey, now i know about the debugging mode. Thank you very much guys!

Viewing 15 replies - 1 through 15 (of 26 total)