Tag Info

Hot answers tagged

5

It is okay that the URL changes to http://mysite.com/contact/#rocket, but you should change the way you are defining your anchor on the target page. Instead of using this method <a name="rocket"></a> <div> <h3>The Title</h3> <p>some text</p> </div> You should add an ID to the content you want to jump to ...


5

The action is update_option_permalink_structure. You get the old and the new value as parameters. add_action( 'update_option_permalink_structure' , 'my_custom_function', 10, 2 ); function my_custom_function( $oldvalue, $_newvalue ) { // do something } There are also the actions update_option_category_base and update_option_tag_base.


2

I did not test this, but this should do what you want. Put the following in your functions.php: add_filter('rewrite_rules_array', 'category_name_rewrite_rule'); function category_name_rewrite_rule($rules) { $new_rules = array(); $categories = get_categories(); foreach ($categories as $category) { $cat_name = preg_replace('#\s+#', '-', ...


2

Since editor displays projected permalink for slug editor, it must have some way to figure it out. From looking at source that is handled by get_sample_permalink_html() and get_sample_permalink(). Since we only need link without form cruft, we can rework it into something like: function get_draft_permalink( $post_id ) { require_once ABSPATH . ...


2

You could use a redirect in your server/site configuration, for example a RedirectMatch in your .htaccess: RedirectMatch permanent ^/\d\d\d\d/\d+/\d+/(.*) /$1


2

This is not natively possible, since in your example permalink structure posts are detected by slug alone, and not combination with category. Essentially category info gets simply discarded. If your requirements involve only one (few) of possible endings for URL you might achieve this relatively easy using endpoints, see add_rewrite_endpoint(). However in ...


1

It sounds like you need to copy the file /blog/index.php to /index.php and modify a line in the new copy you create: require('./wp-blog-header.php'); to require('./wordpress/wp-blog-header.php'); Here is a complete guide to moving Wordpress into a separate folder: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory


1

This will be done when you register_post_type : $args = array( 'rewrite' => array( 'slug' => 'book' ), ); register_post_type( 'book', $args ); IMPORTANT ! Remember to go to wp-admin options > permalink and click SAVE on that page for the changes to take effect.


1

The parameter you are using is wrong. There is no set_front parameter when you register a Custom Post Type. The appropriate parameter is with_front. 'with_front' => bool Should the permastruct be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true ...


1

You may use template redirect action to check if there is parameter set for description and based on that you can show desired template. <?php add_action('template_redirect', 'course_template_redirect', 1); function course_template_redirect() { global $wp_query; if($wp_query->post_type=='courses' and $_REQUEST['showdesc']=='1') { ...


1

If the description and attachments require separate URLs then I would create the 'attachments' as a separate post type to the 'courses' which contain the description. Then from your main custom post type 'courses' I would create reciprocal relationships from each course to its units and attachments using the Posts 2 Posts plugin.


1

The the_permalink() function links to the single post view for the given post-type. As per the Template Hierarchy, the page used to render the single post view is single.php. So, if you want to modify the template used to render the page when clicking the_permalink(), create/modify single.php, or for a specific post-type, create/modify ...


1

I don't have comment capabilities, but the problem is very likely to be on the MS server side, specifically the URL Rewrite module. This is what handles permalinks on IIS. There is a hotfix for this problem, but you should probably apply all the hotfixes available for your system.


1

You could override your query with pre_get_posts in functions.php: function add_all_fruits_to_category($query) { $catnames = $query->get('category_name'); if ($catnames == 'fruits') { $query->set('category_name', $catnames . ',bananas,apples,pears'); } } add_action('pre_get_posts', 'add_all_fruits_to_category');


1

I faced the same problem and just solved the issue after spending close to an hour figuring out the issue. So if your CPT (custom post type) single pages are using the index.php and not the single-post_type template, make sure you're not using query_posts improperly. For me, it turned out that I forgot to call wp_reset_query on one of the sidebar pages ...



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