WordPress/BuddyPress child theme functions.php ignored selectively - wordpress

This is puzzling. I have a child theme (with its own custom functions.php) that works fine except for a handful of pages. For some reason, it's like those handful of pages don't recognize the custom functions.php file.
I have the user filling out a BuddyPress registration form - and then have my functions.php file use the bp_after_registration_confirmed hook to update a few things behind the scenes. The bizarre part is that this works exactly as expected in my development environment - with functions.php responding to the BuddyPress hook. But on the live server, it totally ignores that and just completes registration without invoking my custom function.
Any idea what I may be missing?
What could possibly cause the live server to not see/execute the child theme's custom functions.php file in a handful of instances?
-- UPDATE --
I noticed that for the pages that do not see the child theme's functions.php, they do see functions from the parent theme's functions.php file. Weird, right?

Have you checked if they are using child theme templates?
If they're using parent theme templates, try creating overriding copies of the same template and see if they then use your child themes functions.php

Related

Woocommerce default styles have been lost after adding add_theme_support('woocommerce) code

I wanted to add load more button to Woocommerce shop product's page. For overriding the scripts I have added archive-product.php file and add_theme_support('woocommerce) code in functions.php file.
For functionality I have added everything needed to js and function.php files. Everything works well, but the Woocommerce default styles have been lost after adding add_theme_support('woocommerce) code. How to improve that, besides manually defining in css file.
Thanks in advance.

How to modify WP Job Manager job listings template?

Long story short - where is the template for the listing list items that are shown when the [jobs] shortcode is used?
I have a WP site with WP Job Manager. I am using the [jobs] shortcode to show a list of the jobs that is searchable. I need to modify the template of the listings to show lets say an excerpt of the job offer. I think the template showing there is the content-job_listing.php, but when I modify it nothing happens. So my problem is I can't seem to find the correct template.
I've searched the whole plugin code and can't seem to find anything remote to what is displayed on my page where the [jobs] shortcode is.
So what is happening here you think and where usually is the template I am looking for?
content-job_listing.php ist the corect template for it. What theme are you using? If you are using a WP Job Manager specific theme like Jobify then they probably have a custom template overriding the plugin's template. Then you'd have to look in their documentation to see which file that is.
Where are you editing the file? In a child theme or in the plugin's folder? If you are editing the file in the plugin's folder and you don't see changes then you probably have the file in a child theme as well. The child theme takes priority in that case.
Anyway you should make changes only in a child theme and not in the plugin files to make sure your changes are update-proof. It could also be that you are editing the file in a child theme which is not the active theme in your WP install?
If you haven't done yet check out the official WPJM documentation on this topic: https://wpjobmanager.com/document/template-overrides/

Wordpress - Some child theme files are not recognized in the template

I'm new to template designs and I'm trying out altering some things in the parent theme from the child theme.
My problem is that there are some files that are not recognized, for example the style.css from the child theme does work for me, but there are other files that I need to load in the child theme instead of the parent theme that I am not able to get them to work.
I am trying to get the /inc/core/shortcodes.php file recognized in the child theme, as there is an html <h4> tag that I want to replace with an <h3>.
The file structure is as follows:
Any help would be appreciated, best regards.
Child theme implementation isn't a universal thing in WordPress - each theme implements it in its own way (some very poorly), and not everything is necessarily overwritable through a child theme. Usually, only actual template files are overwritable. The specific file you're referencing (shortcodes.php) likely contains shortcodes added by the theme, not template data, so wouldn't generally be overwritable in that way.
The better way to handle what I suspect you're trying to accomplish (modifying how a specific shortcode works) would either be to use hooks in the shortcode (assuming the developer added them) to manipulate the shortcode output, or copy the shortcode(s) you want to modify into a file in your child theme, change the name (and function name) of the shortcode, and load it from the functions.php file. This also gets more complicated if you're using a theme with a page builder (Gutenberg, Visual Composer, Elementor, Cornerstone, Avia, Avada, Beaver Builder, etc). Most page builders use some form of shortcode under the hood to actually generate the displayed data. If your theme uses a page builder like this, and the shortcode in question has a corresponding element in the page builder, you'll also have to add a button for your modified version (or insert is using the "HTML" or "Code" element) to actually use it - the existing button wouldn't incorporate your changed code. All of the page builders mentioned above can be (and have been) extended in this way.

fullpage.js only on certain pages

is it possible to have fullpage.js only on home page, and on another to have normal web page. So far, when I put framework to work, it work perfectly on home page, but now I want to have another page which is normal, without any scrolling options (I putted code without fullpage and section classes), and it does not work. Can not scroll down at all. Any solutions? I am using wordpress as a cms.
You probably just need to enqueue the plugin conditionally. Register js in your functions.php and the enqueue it only in front-page.php, or what your theme is using for the front. Alternatively you can enqueue it in functions.php in if(is_front_page()) statement.

How use theme's function into plugin's file in Wordpress

I am building a simple plugin of wordpress, and trying to use theme's function into plugin's file, but it is saying "Call to undefined function", while that function exists in themes.php of current active theme.that function is in use in theme's files but can't accessible in plugin's file, can anyone guide what to do?
while I have to attach plugin with theme as mandatory plugin.
Thank you
Plugins are loaded before the theme so the function hasn't been defined at the time you're calling it. Execute your code on a hook such as init instead.
E.g.
function wpse_my_plugin_init() {
myPreviouslyUndefinedThemeFunction();
}
add_action( 'init', 'wpse_my_plugin_init' );
See here for a list of hook options: https://codex.wordpress.org/Plugin_API/Action_Reference
The earliest opportunity you have to call this code would be after_setup_theme.
On another note I'd suggest rethinking this approach. A plugin should be an independent module; it shouldn't be tied to your theme.
Your approach/design is serious flawed. Plugin functionality should never rely on theme functionality. As already pointed out by #NathanDawson, plugins get loaded first, then child theme functions then parent theme functions, so your approach will never work as indented or without a lot of unnecessary bloated code
Plugins are meant to extend site functionality, and not theme functionality. I think this is where your idea is seriously flawed, and most probably due to a lack of knowledge on who should do what and when
As I have stated, plugins should give functionality to the site. Functionalities like favicons, custom post types, custom taxonomies, shortcodes, widgets, related posts and rewrite rules should be in a plugin. This gives functionality to your site, which simply mean, when you change the theme, these functionalities won't change or they won't be affected. Also, if the plugin is removed, it doesn't change the way how the theme looks and operate.
Theme specific functions are functions that gives functionality to the theme itself. Without these functions, the theme looses functionality or its looks. It simply means thant the theme changes. These functions includes functions to enqueue your stylesheets and scripts, theme suppport functions, sidebars, custom headers and backgrounds and registering image sizes.
If you are going to make a plugin rely on theme code, you should be looking to create a child theme, as child themes are meant to extend the main theme. Child themes inherit all functionalities from the parent theme, and can extend, modify or add new functionality to the parent theme.
To conclude, by making a plugin rely on theme code, you are making your site very vulnerable to breakage. If you change your theme, you will break your site as you will break your plugin. This is not how plugins and themes were made to interact. By creating a child theme instead, you void that risk as child themes cannot be activated without the parent theme being in the theme's folder and neither can any two themes be activated at the same time.

Resources