Make use of the functions wordpress offers to determine paths and URLs – see Determining Plugin and Content Directories. For example use:
-
Retrieves the absolute path to the directory of the current theme, without the trailing slash.
-
or get_stylesheet_directory to
Retrieve stylesheet directory Path for the current theme/child theme.
You find more information on the linked codex page about determining directories.
Edit: In response to the comment.
This is how I’d do it:
function mytheme_get_theme_mods() {
$tpl_dir_pth = get_template_directory();
$defaults = array(
'mytheme_header_logo' => $tpl_dir_pth . '/img/logo.png',
'mytheme_footer_logo' => $tpl_dir_pth . '/img/footerlogo.png',
'mytheme_middle_image' => $tpl_dir_pth . '/img/middleimg.png'
);
return $defaults;
}
Of course I don’t know if the absolute path actually is what you want.
Related Posts:
- How to get the registered sidebar’s name by its id?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- One button to change all settings in theme customizer?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Design view breaking on Pages
- Can’t load WP function into external function
- Set WordPress Default Template
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- How do I link a button I created in theme customizer to a function?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- get_template_directory adding FTP root folders in urls
- How can I assign separate stylesheets to different pages?
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Menu to the right of screen on desktop using Bootstrap 4
- How to store the_title() into a variable to reutrn the value, not just echo it
- reason of splitting theme files to multiple files
- Dynamically change feature image in customiser
- Understanding WordPress child theme custom JS loading
- How can I loop into two different DIVS without repeating the DIVs
- Removing unnecessary wordpress files
- Need to get specific data from array
- Use different javascript files for each page on website
- Is the regular ajax request method safe or I should use admin-ajax.php?
- How to get custom image size for image uploaded in Customizer
- Create an array from an array
- Passing array in add_option()
- Can I change a variable in a content part while calling it?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Changing the template hierarchy
- Customizer: Output default value in Customizer CSS
- WordPress does not load page.php, return 404.php
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Converting HTML Template to WordPress Theme
- WordPress add post format support not working
- How to remove the cufon script from Dzonia Lite theme [closed]
- Populate dropdown with Child Pages based on Parent Page chosen
- How do I add custom bulk actions to multiple custom post types?
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- what is the best practice to add new field to an api route
- foreach loop still echoes array
- Error in custom php function doesn’t exist
- Customizer: active_callback and sanitize_callback incompatibility?
- Populate editor with some content of a page with a page template
- Skt full width basic slideshow problem
- How to disable controls in theme customizer?
- Alter required message using comment form api
- What does this mean in wordpress? Easy question
- meaning of (array)function()
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- WordPress Customizer Default Image
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- How to use array in function to get only value I want
- What is the best way to define constant options for a theme?
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- Save Custom CSS file in the upload folder dynamically?
- Warning: in_array() null given in PHP function
- Warning: printf(): Too few arguments in helpers.php file
- Getting posts to exclude from array
- home.php show blog posts as grid view
- Removing “Powered by” footer using child theme PHP [closed]
- Get css class of menu item in custom menu structure
- get_page_templates only return templates with “home” in the filename
- Is there a hack for using is_page() within the function.php file?
- Randomize Color Scheme Selection in Theme
- Extract and display user infromation on an automatically created page
- Show different website layout if no sidebar added
- Need advice on theme customizer and child themes
- Commas in Tag Cloud
- WordPress redirects page query parameter in URL
- Getting text from custom field from customizer
- How to change basename url for wp-admin?
- how to replace h1 entry title with h2 in category pages only
- Not able to remove caption shortcode from the content
- File from parent theme imported to child theme doesn’t work – any ideas?
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Display post date also if the date it’s the same for each post
- How to override theme’s public static function inside of a trait?
- how to use 2 index.php file One for mobile and one for desktop
- Store custom field’s multiple values in one user meta key
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Theme editing “post thumbnail” help
- Display posts using post ID’s in an array
- Use Custiomizer to setup meta theme color tag
- Rotating Header Images
- Where can I find the declaration of `$_wp_theme_features`?
- Create a custom theme-specific page, invisible in the admin-panel?
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Save the outputted image into the Media Library, with a different filename and extension
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Image not displayed
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- Adding code to the function file
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme