Forums

Tag permalinks doesn't seem to work?? (3 posts)

  1. DDT
    Member
    Posted 2 years ago #

    Hi all,

    I am having troubles getting the permalink for tags to work
    for example
    mydomain.com/tag/creeper

    doesn't give me the posts with creeper as tag

    I didn't change my htaccess as browsing by category seems to work fine.

    mydomain.com/category/baby-products/

    my .htaccess looks like

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /products/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /products/index.php [L]
    </IfModule>

    Any tips?

  2. fenixsz
    Member
    Posted 2 years ago #

    Yesterday I found solution for me on this topic somewhere in wordpress formum:

    /wp-inludes/link-template.php

    Change this code with original:

    /**
     * Retrieve full permalink for current post or post ID.
     *
     * @since 1.0.0
     *
     * @param int $id Optional. Post ID.
     * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
     * @return string
     */
    function get_permalink($id = 0, $leavename = false) {
    	$rewritecode = array(
    		'%year%',
    		'%monthnum%',
    		'%day%',
    		'%hour%',
    		'%minute%',
    		'%second%',
    		$leavename? '' : '%postname%',
    		'%post_id%',
    		'%category%',
    		'%author%',
    		$leavename? '' : '%pagename%',
    	);
    
    	if ( is_object($id) &amp;&amp; isset($id->filter) &amp;&amp; 'sample' == $id->filter )
    		$post = $id;
    	else
    		$post = &amp;get_post($id);
    
    	if ( empty($post->ID) ) return false;
    
    	if ( $post->post_type == 'page' )
    		return get_page_link($post->ID, $leavename);
    	elseif ($post->post_type == 'attachment')
    		return get_attachment_link($post->ID);
    
    	$permalink = get_option('permalink_structure');
    
    	if ( '' != $permalink &amp;&amp; !in_array($post->post_status, array('draft', 'pending')) ) {
    		$unixtime = strtotime($post->post_date);
    
    		$category = '';
    		if ( strpos($permalink, '%category%') !== false ) {
    			$cats = get_the_category($post->ID);
    			if ( $cats ) {
    				usort($cats, '_usort_terms_by_ID'); // order by ID
    				$category = $cats[0]->slug;
    				if ( $parent = $cats[0]->parent )
    					$category = get_category_parents($parent, false, '/', true) . $category;
    			}
    			// show default category in permalinks, without
    			// having to assign it explicitly
    			if ( empty($category) ) {
    				$default_category = get_category( get_option( 'default_category' ) );
    				$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
    			}
    		}
    
    		$author = '';
    		if ( strpos($permalink, '%author%') !== false ) {
    			$authordata = get_userdata($post->post_author);
    			$author = $authordata->user_nicename;
    		}
    
    		$date = explode(" ",date('Y m d H i s', $unixtime));
    		$rewritereplace =
    		array(
    			$date[0],
    			$date[1],
    			$date[2],
    			$date[3],
    			$date[4],
    			$date[5],
    			$post->post_name,
    			$post->ID,
    			$category,
    			$author,
    			$post->post_name,
    		);
    		$permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
    		$permalink = user_trailingslashit($permalink, 'single');
    		return apply_filters('post_link', $permalink, $post, $leavename);
    	} else { // if they're not using the fancy permalink option
    		$permalink = get_option('home') . '/?p=' . $post->ID;
    		return apply_filters('post_link', $permalink, $post, $leavename);
    	}
    }
    
    /**
     * Retrieve permalink from post ID.
  3. tommyk421
    Member
    Posted 2 years ago #

    Be warned that support for %tag% in permalinks might be dropped by 2.9, according to this TRAC entry (read the bottom few posts).


    http://core.trac.wordpress.org/ticket/9466

Topic Closed

This topic has been closed to new replies.

About this Topic