Tag Info

Hot answers tagged

23

I think you have to be a little careful because it depends on what you are trying to do. If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths. If you wanted a fully formed URI, ...


10

Symbolic links are … risky in WordPress. It is easier to use a separate domain for plugins per wp-config.php: define( 'WP_PLUGIN_DIR', '/local/path/to/plugin/directory' ); define( 'WP_PLUGIN_URL', 'http://plugins.dev'); See Strategy On Building Plugin Using Eclipse as an example for IDE configuration with such a setup.


8

What you're looking for is wp_localize_script function. You use it like this when enqueing script wp_register_script( 'my-script', 'myscript_url' ); wp_enqueue_script( 'my-script' ); $translation_array = array( 'templateUrl' => get_stylesheet_directory_uri() ); //after wp_enqueue_script wp_localize_script( 'my-script', 'object_name', $translation_array ...


7

The post format taxonomy: The post format is a default taxonomy, registered with: register_taxonomy( 'post_format', 'post', array( 'public' => true, 'hierarchical' => false, 'labels' => array( 'name' => _x( 'Format', 'post format' ), 'singular_name' => _x( 'Format', ...


7

They should do the same thing, but under certain conditions, may not. First of all note: that the codex entry description is misleading that wp-admin/includes/file.php must be included in context else calling get_home_path() will lead to calling an undefined function. Regarding the codex entry, Description Get the absolute filesystem path to ...


6

I don't have time to explain this in detail (I shall upon return) but in the meantime this should work for you, Answer updated with explanation as promised. WP Rewrite rules are like voodoo, I'm sure there's more than one way to go about this, but here's mine. Problem: Just to clarify your question for others who may stumble upon this thread, what you ...


6

You can change the Plugins directory using constants defined in wp-config.php: Set WP_CONTENT_DIR to the full local path of this directory (no trailing slash), e.g. define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-content' ); Set WP_CONTENT_URL to the full URI of this directory (no trailing slash), e.g. define( ...


5

The forward slash works on every operating system supported by PHP. Yes, on Windows too. It is also more readable and easier to type, so there is no need to use the constant. See the tickets #20849 and #15598 for related discussion on Trac.


5

The best way would be to use wp_nav_menu with a custom walker. Prerequisites: Registered theme location Menu saved to that theme location Useage Wherever you want the breadcrumbs (for theme location 'primary'): <?php wp_nav_menu( array( 'container' => 'none', 'theme_location' => 'primary', 'walker'=> new SH_BreadCrumbWalker, ...


5

You need to reference your WordPress template directory when you register the script. Change this: wp_enqueue_script('my_javascript_file', '/javascripts/app.js', array('jquery')); ...to this: wp_enqueue_script('my_javascript_file', get_template_directory_uri() . '/javascripts/app.js', array('jquery')); Codex reference: get_template_directory_uri()


5

You can use admin_url() function for wp-admin.css file and ABSPATH for admin.php. $admin_php_path = ABSPATH . '/wp-admin/admin.php'; $admin_css_url = admin_url( 'css/wp-admin.css' );


4

If you just need that class included, and your script is located in the plugin directory, like /wp-content/plugins/pluginName/script.php, then you can do: require realpath('../../../wp-includes/class-phpass.php');


3

You need to set the WP_HOME and WP_SITEURL in wp-config.php in a smarter way. Like this: <?php define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); // add the next line if you have a subdirectory install define('WP_SITEURL', WP_HOME . '/path/to/wordpress'); This will solve your your issues with site URLs as they will be set dynamically on based on ...


3

Short Answer jquery-ui.widget is one of standard scripts already included and registered in WP. You don't need to register it, just enqueue. In your code what is wrong is the dirname function inside plugin_url. Leave only __FILE__ as second argument of plugins_url Long Answer: More Info jquery-ui.widget is one of standard wordpress scripts so, in most ...


3

get_template_directory(); http://codex.wordpress.org/Function_Reference/get_template_directory


2

Always use the built-in versions. Don’t waste time with old WordPress installations – other plugins will break there too. See wp-includes/script-loader.php for the list of available files. Quite a lot. :) And avoid remote resources. Some (Google) fail to send the scripts gzip compressed to all supporting browsers, others may not be reliable enough. There ...


2

If this is a single WordPress install, there are a couple database entries with your old domain. Specifically, siteurl and home within wp_posts. That said, if the dev URL is temporary, you can also set the following two constants in wp-config.php: define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']); define('WP_SITEURL', WP_HOME . '/'); Provided that ...


2

The function plugin_dir_path has an misleading name, it doesn't include a file from plugin directory, it just include a file from the same directory of the file passed as argument. When you call include( plugin_dir_path( __FILE__ ) . 'test-plugin/needed_file.php'); from a file in theme directory, you are just trying to include a file from theme directory ...


2

These are the following two ways to add theme path in javascript file. 1) You can use wp_localize_script() suggested by wordpress in your functions.php file. This will create a Javascript Object in the header, which will be available to your scripts at runtime. Example : ...


2

You can place the page templates wherever you want (also in a separate folder) as long as the files are within the current or parent theme's directory. UPDATE: Follow this link to get a more detailed information about the Template File Folders: http://codex.wordpress.org/Page_Templates#File_Folders Take also a closer look at the Page Templates and the ...


2

With WordPress 3.4 was a change that allowed you to place your custom page templates in a subdirectory of your choice. The subdirectory can be named anything you want, but it needs to be in your active theme's main folder.


2

get_stylesheet_directory_uri() is a PHP function, you must use it in a PHP file instead of your CSS file. In your functions.php you can paste this code and change depends on your needs: function my_login_logo() { ?> <style type="text/css"> body.login div#login h1 a { background-image: url(<?php echo ...


2

You will want to run a find-and-replace script across the database to update all URLs to reflect the new domain. Just because you change the WordPress settings doesn't mean the content stored in the database has been updated with the new domain! I've had good luck with the Velvet Blues Update URLs plugin but you can also do this type of find and replace ...


1

WordPress would allow this (sort of). You would still need to create an About page in the back end, but you can tailor your display for such a page 2 different ways: Page Templates Page template hierarchy - What this means is there is a certain order of what WordPress is looking for when displaying any page/post. Check out the image here for a more direct ...


1

insert.php file that I made myself, actually I am new to wordpress, I want to that is there any mistake that i am making? Actually I want to store a plugin form information in the database. Your question is very light on detail but I suspect that the mistake you are making is loading a file in such a way as it loads outside the context of WordPress, ...


1

There are several locations in the database where the URL is stored. You will need to go into those locations and change mymu to somethingelse. I made a list for myself on my blog, feel free to use it! :) Step 5 has the list of tables you need to alter.


1

Until this gets fixed, the only workaround I can see is to intercept the $_POST data and add extra slashes prior to ACF stripping them: /** * @link http://wordpress.stackexchange.com/q/143555/1685 */ function wpse_143555_acf_add_slashes() { if ( ! empty( $_POST['fields'] ) ) { foreach ( $_POST['fields'] as $k => $v ) { if ( ! ...


1

So I'm taking some liberties with this, I'm assuming a couple things: You know the taxonomy the term belongs to You have the term archive link So if I have the term archive link: $url = 'http://www.example.com/taxonomy/term/'; I know that the last part of that url is going to be the terms slug. I can use the slug with the taxonomy and get the ID but ...


1

There's a few plugins to fix this, but basically it your database still references the images to be "oldsite.com/wp-content/uploads/" and you need it to be "newsite.com/wp-content/uploads" So you have to change all old references. You could use SQL: UPDATE wp_options SET option_value = replace(option_value, ‘http://www.oldsite.com’, ...


1

Use wp_localize_script() to pass any kind of data to your loaded scripts, in this case we need plugins_url(): wp_enqueue_script('my-script', get_stylesheet_directory_uri() . '/js/my-script.js'); wp_localize_script('my-script', 'myScript', array( 'pluginsUrl' => plugins_url(), )); Now you will have access to myScript.pluginsUrl in your script file: ...



Only top voted, non community-wiki answers of a minimum length are eligible