Tag Info

Hot answers tagged

9

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.


7

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

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

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

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


4

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


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

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


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

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


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

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

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


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


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

I don't know what "wp vip" wants or needs, but you should be loading files by means of get_template_part, locate_template, site_url, or home_url and I am guessing that using one or more of those is what the "scan" wants. It is hard to say exactly which since you posted only the error and not the source that goes with the error.


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

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 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' );


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

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

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


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

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

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=("|\')'. ...



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