Tag Info

Hot answers tagged

8

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.


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

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 ...


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()


4

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 ...


3

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( ...


3

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 ...


3

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, ...


2

If the image is purely decorative and non-essential, you might consider doing this with CSS's :before attribute. Something like: .menu-item:before { display:inline-block; content:''; width:20px; height:20px; background: url(images/icon.png) no-repeat; } Otherwise, @brasofilo's answer is right. UPDATED 9/21/12: Also, icon fonts are all the rage ...


2

You have two problems in your code: the function bloginfo will print the information, and you only need to pass it to the wp_nav_menu function, so the correct function would be get_bloginfo also, in situations like this: echo 'html_code'.php_function().'other_html_code' you don't use the semicolon after the php function And as a last comment, instead of ...


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

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 : ...


1

Call get_stylesheet_directory_uri() for the current theme, or get_template_directory_uri() for the parent theme of a child theme, and append your file paths to that. $url = get_stylesheet_directory_uri() . '/images/my-icon.png'; $url = get_template_directory_uri() . '/images/my-icon.png'; Edit: To determine whether you're in a plugin, a parent theme or a ...


1

If I understand you, don't use 'localhost'. That only works if you are testing from the same machine that is running the server. (A virtualized machine counts as a different machine.) Give your server (the machine running the server) a static IP address-- something like 192.168.1.5-- and use that instead of 'localhost'. That will work for any machine on your ...


1

Go to Settings > Permalinks and insert archive in the Category base field. For custom post type archives, you can set that to anything you want via the has_archive argument of register_post_type: 'has_archive' => 'archive/your-post-type'


1

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 ...


1

Something like this should do it, you may have to fiddle with the preg_replace() to get it to work the way you need, but the concept (and, more importantly imo, the regex, is there). if( is_single() ) { add_filter( 'the_content', 'wpse44503_filter_content' ); } function wpse44503_filter_content( $content ) { $regex = '#src=("|\')'. ...


1

wp_upload_dir() is perfect. It is the only place where you can expect write permissions. Store the attachment ID, not a path. Then you get the image with: wp_get_attachment_url( $attach_id ) Sometimes a user may have deleted the image per media library. To avoid problems with missing files check the return value from wp_get_attachment_url() first. ...


1

I think you should run a custom mySQL query to the wp_posts table, something like - SELECT ID FROM `wp_posts` where guid like '%filename.jpg'; (of course use $wpdb object to query the databse). Then you will have the postid of that attachment file and you can use wp_get_attachment_url() from the WP API.


1

Try changing the WP_CONTENT_DIR path in wp-config.php Try adding: define( 'WP_CONTENT_DIR', 192.168.X.X . '/blog/wp-content' ); http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content



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