remove permalink trailing slash

You can use the trim command to do this, specifically, the rtrim to remove the character from the right side: $url = rtrim(get_permalink(),”https://wordpress.stackexchange.com/”); Using a blanket substr -1 technique would cause problems if there isn’t a trailing slash in the permalink. Also, the function the_permalink echoes the link, and get_permalink returns it as a string.

How to add nofollow on all external links without plugin?

This is how I would do it : 1/ create a filter to access the post content before it’s displayed on page. See http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2/ Inside your fonction called (ie : my_the_content_filter in the example from the Codex) adapt this code : https://stackoverflow.com/questions/5037592/how-to-add-rel-nofollow-to-links-with-preg-replace Cheers !

Get link of inserted media file of post within loop

You can get attachment URL like this. <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/163795/<?php $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),”full’ ); echo $featured_image_url[0]; ?>”> <?php the_title(); ?> </a> <?php endwhile; endif; ?> First you will need to get the attachment ID so you will need to get it from … Read more

How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name

When you create permalink structures like /article/%category%/%postname%/, it becomes very complicated when %category% is hierarchical. The problem WordPress runs into is knowing if after the second slash, the next part of the URL is a category or a post. For instance, in the url /article/parent/child/, is “child” a subcategory of “parent”, or is it a … Read more

Permalinks without subdirectories

One solution would be to create all your pages as root pages and then use the Menu page in “Appearance -> Menus” to define the structure of the pages. This assumes that your theme supports Menus, which the default WordPress themes TwentTen and TwentyEleven do. Update: Here’s a couple of links that might help you … Read more

Remove POST_TYPE from custom post type permalink

As @WebElaine commented on this question I tried the following code which worked for me. First, remove the slug from the permalink function na_remove_slug( $post_link, $post, $leavename ) { if ( ‘services’ != $post->post_type || ‘publish’ != $post->post_status ) { return $post_link; } $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, $post_link ); return … Read more