Under theme customisation, I'm unable to set a video as the Header Media. This theme is being created from scratch so I've currently only got the following files: header.php, footer.php, functions.php, sidebar.php, index.php
I've tried setting video to true in the theme support section for wordpress. I've tried copying the implementation in the twentyseventeen theme.
I've tried different combination of parameters in the custom-header theme support function.
functions.php:
add_theme_support( 'custom-header', array(
'video' => true,
) );
header.php:
<?php the_custom_header_markup(); ?>
Wordpress is currently giving me the following error:
"This theme doesn’t support video headers on this page. Navigate to
the front page or another page that supports video headers."
In my functions.php I was loading jQuery like the following:
wp_enqueue_script('wptheme-jquery-js-cdn', 'https://code.jquery.com/jquery-3.3.1.slim.min.js');
This caused jQuery to load first. To solve this, I forced it to be loaded in the footer.
wp_enqueue_script('wptheme-jquery-js-cdn', 'https://code.jquery.com/jquery-3.3.1.slim.min.js', array(), '', true);
This is also better practice to stop it blocking rendering.
Related
I'm working in custom wordpress theme but wondering how wordpress decides to which link or script should be added in footer or which script should be added in header because we add all the links in the functions.php without mentioning that where it needs to be added.
Would be great if anyone could explain!
We usually use the wp_enqueue_script function for including any script or style's file. In this function you can see there are few parameters are allowed.
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
You can see the last parameter us $in_footer, you can set it true if you need to load the script/style in the footer. By default it is false and load in the <head> area.
For more details you can read the official information here.
I'm developing my first WordPress plugin for an internship.
I know how to put style on the admin pages by wp_enqueue_style() and admin_enqueue_scripts. I also know wp_enqueue_scripts.
I created a custom post type to store businesses and a single template page in "templates" folder, called "single-myCPT.php".
The problem is: I don't understand how to call a css file for this single page.
The URL is like : mywebsite/myCPT/company
When I use the inspector and I go on "Network", there is no css file detected.
Sorry for my English, I'm a French guy who wants to improve that language :).
You can use wp_enqueue_style() and wp_enqueue_script() on front-end (non-admin) pages as well as admin pages.
Use the wp_enqueue_scripts action for the purpose.
function plugin_name_enqueue_frontend_style() {
wp_enqueue_style(
'plugin_name_frontend',
plugin_dir_url( __FILE__ ) . 'css/frontend.css');
}
add_action( 'wp_enqueue_scripts', 'plugin_name_enqueue_frontend_style' );
But, you should probably also include your frontend css on your admin page; you may need it.
I am using the divi theme and had a simple line of javascript running in footer.php:
<script>
console.log("inside of footer.php");
</script>
Then, i used Divi Theme Builder to make a custom footer and found that footer.php was no longer running. I need to add javascript back into the footer but can't figure out what file to enter it in. How do I place javascript into the footer?
It is not recommended at all to edit the footer.php template in an external theme.
The way we use this is.
Go to your_page/wp-content/themes/active_theme_name
Create a custom.js
Then in the functions.php add this line:
wp_enqueue_script( 'customjs', get_template_directory_uri() . '/custom.js', array ( 'jquery' ), 1.1, true);
Read, now you can write your console.log("inside of footer.php"); in a custom.js file.
Here's a brief tutorial by the creators of Divi covering how to include javascript on your Divi website.
https://www.elegantthemes.com/blog/divi-resources/best-practices-for-using-external-javascript-snippets-with-divi
Assuming you want to include your code in the footer for UX/SEO reasons, then the best route is probably to go to Divi > Theme Options > Integration and paste your code in the Add code to the <body> section.
This will insert your code immediately before the closing </body> tag on all your pages.
I am making a wordpress store using storefront theme named Pakoutfit.com.
I tried to edit its footer credentials using My Custom Functions plugin and using this plugin I run following code,
add-action( 'init' , 'custom_remove_footer_credit' , 10 );
function custom_remove_footer_credit(){
remove_action( 'storefront_footer' , 'storefront_credit' , 20 );
add_action( 'storefront_footer' , 'custom_storefront_credit' , 20 );
}
function custom_storefront_credit(){
?>
<div class="site-info">
© PakOutfit <?php echo get_the_date( 'Y' ); ?>
</div>
<?php
}
I do that following this youtube tutorial,
Now when I tried to open my site or even its wp-admin panel it says,
This page isn’t working
pakoutfit.com is currently unable to handle this request.
HTTP ERROR 500
I dont know that in which file My custom Functions plugin make changes so that I can reverse them.
I am using godaddy domain name and hosting.
I am new in this field. Please help me to make my site live again. Thanks
Modification to your site should be made via a WordPress child theme. Do not edit core theme files: https://codex.wordpress.org/Child_Themes
Using your FTP or cPanel login, locate the file where you made the changes and remove them. That will restore your site.
Once you have your child theme installed and activated, and your function to the child theme functions.php file.
Be sure to change this:
add-action
To this:
add_action
I am working on a WP plugin that uses bootstrap. However, it seems to be having a very strange affect on the page. You can see it here:
My Test Page
If you go to this page, then go to another, you will see that the page goes back to normal.
How can I prevent bootstrap from affecting the WP elements on the page?
add_action( 'wp_enqueue_scripts', 'bootstrap_css', 150 );
function bootstrap_css(){
// add pages for bootstrap leave out site address, just the path e.g.
$pages= array( '_3_8_0/rentals/','add_page_url' );
$path=$_SERVER['REQUEST_URI'];
if( !in_array($path, $pages) ):
wp_dequeue_style( 'bootstrap_handle' ); // look up handle for stylesheet
endif;
}
You can do something like the above to de_queue the bootstrap css on pages that you dont want it on. The problem is Bootstrap is not really designed for singular page use with a existing theme and will share a lot of common identifers with what your theme uses e.g. "content"
its either that or remove bootstrap altogether (just de-queue it) and style the page yourself. To be honest bootstrap is a heavy load for the use case here.