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
- Using a variable in is_page(array())
- Trigger popup in a php if/else statement
- 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]
- get_the_tags() not iterating through for/while loop, but will with foreach
- get a simple array of all of the term names that exist in all taxonomies
- 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
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7
- Checking array against author id in loop
- Skt full width basic slideshow problem
- How to disable controls in theme customizer?
- Trying to retrieve post meta
- Is there a way to conditionally check whether a WordPress post title is empty?
- Redirect to another page using contact form 7? [closed]
- Alter required message using comment form api
- WordPress admin-ajax.php
- Use .php file as page instead of wordpress page & template file?
- Use WordPress function in php file
- What does this mean in wordpress? Easy question
- meaning of (array)function()
- How to obtain the current website URL in my theme?
- What exactly do this function declared into functions.php file of a WP theme?
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- wp_force_remove_style’ not found
- Reason to add a name of the theme like (‘menu-1’ => __( ‘Primary’, ‘twentynineteen’ ),) in PHP?
- Separation of presentation and code – WordPress
- 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
- Filtering a function’ output for a new continued function
- WordPress Customizer Default Image
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Why in my theme I can’t see all the statics content under the posts?
- 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?
- Theme not calling Jquery properly
- 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
- How to make function appear in sentence?
- Loop over Array and get the distinct ids
- If Array Values Match Another Array’s Values, Then
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- home.php show blog posts as grid view
- blank white page when post/update/change option etc
- How to Update an old theme for the latest wordpress version
- get_comments_number() returns 0
- Removing “Powered by” footer using child theme PHP [closed]
- Get css class of menu item in custom menu structure
- How to add aria role and schema markup to custom walker container
- 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
- Only load certain artists on this page
- Show different website layout if no sidebar added
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- Displaying Slider in Front Page (home) using Customizr Theme
- Need advice on theme customizer and child themes
- call a string/function from database
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Commas in Tag Cloud
- Custom functions for string data calculations
- WordPress redirects page query parameter in URL
- Getting text from custom field from customizer
- Need help for some PHP code
- 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
- When I click for the redirect link it is showing the content of index.php instead of single_assignment_page.php