Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7363

    Heya,

    Currently, I have the url for my portfolio items as sitename.com/laugh/funny-pictures/’name of item’… problem is.. that first bit is hard coded in, and I want to add a section containing videos (and there will be sub categories thereof), which obviously will need a different URL. lol.

    How do I change the portfolio to use the full /%category%/%postname%/ permalink structure that I have my ‘normal’ posts using?

    This probably goes a bit beyond the scope of what is covered by the support, so I’m happy to part with a few dollars for the solution.. my main issue here is time (or lack thereof).

    Any and all help is greatly appreciated. :-)

    ~LazyBear

    #57653

    Also, it doesn’t really both me if there needs to be some element of an initial slug prior to the ‘/parent_category/child_category/portfolio_item_name’ bit..

    i.e. “http://www.example.com/media/parent_category/child_category/portfolio_item_name” would also work.

    On a side note, the original suggestion Kriesi helped me with back at the start of the year to change /portfolio/ to /laugh/funny-pictures/ was this:

    theme_options/portfolio.php – line 54

    Change this:

    rewrite=>’true’ ,

    To this:

    ‘rewrite’ => array(‘slug’=>’/laugh/funny-pictures/’,’with_front’=>true),

    But.. well.. that doesn’t really help solve my current problem.

    Any suggestions? I’m in quite the bind with this one. >.<

    #57654

    I haven’t tried the mod but maybe this tutorial will help you : http://xplus3.net/2010/05/20/wp3-custom-post-type-permalinks/

    #57655

    Hi Dude,

    Yeah… I’ve actually been working through that one for a while (and part 2 – http://xplus3.net/2010/10/04/wp-rewrite-tags-in-permalinks/), and he makes sense until the ‘Putting Things Together’ bit, and then I totally lose what he’s saying. lol.

    Combining it with this (http://www.deluxeblogtips.com/2010/07/custom-post-type-with-categories-post.html), and so far I’ve got no initial slug, normal categories, tags, and custom fields for my portfolio items.. but can’t seem to get the /parent_category/sub_category/ but to work. lol.

    Now they’re just example.com/portfolio_item, lol.

    From what I understand, it involves using add_filter and then using str_replace, but I can’t figure out exactly how to do it.

    My head hurts >.<

    #57656

    OK… here’s where I am at so far.. I have categories (normal and special) showing and applying on my portfolio items, but I can’t seem to get either to actually go as part of the damn URL. I’ve tried everything I can think of, and everything that anyone else seems to have written about. At this stage, I don’t care if it is the taxonomy ‘Portfolio Categories’ or the standard WP categories that gets appended to this URL, as long as it’s one of them.

    My portfolio.php file currently looks like this:


    <?php

    $pageinfo = array(‘full_name’ => ‘Portfolio Options’, ‘optionname’=>’portfolio’, ‘child’=>true, ‘filename’ => basename(__FILE__));

    $options = array (

    array( “type” => “open”),

    array( “name” => “Portfolio Image Link”,

    “desc” => “When clicking on a Portfolio Image what should happen?”,

    “id” => “portfolio_click”,

    “type” => “radio”,

    “buttons” => array(‘Big Image opens in Lightbox’,’Show Portfolio Single Post’),

    “std” => 1),

    array( “type” => “close”),

    array( “type” => “portfolio”,

    “taxonomy” => “portfolio_entries”

    )

    );

    $options_page = new kriesi_option_pages($options, $pageinfo);

    ######################################################################

    # POST TYPE

    ######################################################################

    add_action(‘init’, ‘portfolio_register’);

    add_action(‘init’, ‘portfolio_add_default_boxes’);

    add_action(‘init’, ‘portfolio_taxonomy’);

    function portfolio_add_default_boxes() {

    register_taxonomy_for_object_type(‘category’, ‘portfolio’);

    register_taxonomy_for_object_type(‘post_tag’, ‘portfolio’);

    }

    function portfolio_register() {

    $labels = array(

    ‘name’ => _x(‘Portfolio Items’, ‘post type general name’),

    ‘singular_name’ => _x(‘Portfolio Entry’, ‘post type singular name’),

    ‘add_new’ => _x(‘Add New’, ‘portfolio’),

    ‘add_new_item’ => __(‘Add New Portfolio Entry’),

    ‘edit_item’ => __(‘Edit Portfolio Entry’),

    ‘new_item’ => __(‘New Portfolio Entry’),

    ‘view_item’ => __(‘View Portfolio Entry’),

    ‘search_items’ => __(‘Search Portfolio Entries’),

    ‘not_found’ => __(‘No Portfolio Entries found’),

    ‘not_found_in_trash’ => __(‘No Portfolio Entries found in Trash’),

    ‘parent_item_colon’ => ”

    );

    $args = array(

    ‘labels’ => $labels,

    ‘taxonomies’ => array(‘category’, ‘post_tag’, ‘portfolio_entries’),

    ‘public’ => true,

    ‘show_ui’ => true,

    ‘exclude_from_search’ => false,

    ‘capability_type’ => ‘post’,

    ‘hierarchical’ => true,

    ‘rewrite’ => array(

    ‘slug’=>’media’,

    ‘with_back’=>false

    ),

    ‘query_var’ => true,

    ‘show_in_nav_menus’=> false,

    ‘menu_position’ => 5,

    ‘supports’ => array(‘title’,’thumbnail’,’excerpt’,’editor’,’comments’,’custom-fields’,’revisions’,’page-attributes’)

    );

    register_post_type( ‘portfolio’ , $args );

    }

    function portfolio_taxonomy() {

    register_taxonomy(“portfolio_entries”,

    array(“portfolio”),

    array( “hierarchical” => true,

    “label” => “Portfolio Categories”,

    “singular_label” => “Portfolio Categories”,

    “rewrite” => true,

    “query_var” => true

    ));

    }

    add_action(‘admin_init’, ‘flush_rewrite_rules’);

    #portfolio_columns, <- register_post_type then append _columns

    add_filter(“manage_edit-portfolio_columns”, “prod_edit_columns”);

    add_action(“manage_posts_custom_column”, “prod_custom_columns”);

    function prod_edit_columns($columns){

    $newcolumns = array(

    “cb” => “<input type=”checkbox” />”,

    “title” => “Title”,

    “portfolio_entries” => “Categories”

    );

    $columns= array_merge($newcolumns, $columns);

    return $columns;

    }

    function prod_custom_columns($column){

    global $post;

    switch ($column)

    {

    case “description”:

    #the_excerpt();

    break;

    case “price”:

    #$custom = get_post_custom();

    #echo $custom["price"][0];

    break;

    case “portfolio_entries”:

    echo get_the_term_list($post->ID, ‘portfolio_entries’, ”, ‘, ‘,”);

    break;

    }

    }


    AAAAAhhhhhhhhhhhhhhhhhhhhhhh!!!!!!!!!!!!!!!!

    It’s 2:36am.. I’ve been going around in circles for 4 hours now.. :’-(

    #57657

    Hi,

    Through a process that involves more nasty looking hacks and work-arounds than I dare repeat, I have a mostly-functional workaround.

    It’s not ideal. It’s by no means any sort of recommended plan of attack, and it involves a mix of categories, portfolio categories, page-attributes, parent portfolio items, custom templates for custom post, and other assorted crap… but it works.

    So.. um… ‘yay’.. I think. lol.

    #57658

    Glad that you found a solution. Basically following code outputs the right url – however it doesn’t work for me – the url itself is correct but I get a 404 error when I try to view portfolio items…

    add_filter('post_type_link', 'my_post_type_link', 1, 3);
    function my_post_type_link( $post_link, $post = 0, $leavename = FALSE ) {
    if ( strpos('%issue_project%', $post_link) === 'FALSE' ) {
    return $post_link;
    }
    if ( is_object($post) ) {
    $post_id = $post->ID;
    } else {
    $post_id = $post;
    $post = get_post($post_id);
    }
    if ( !is_object($post) || $post->post_type != 'portfolio' ) {
    return $post_link;
    }

    $portfolio_cat = '';
    $portfolio_cat_slug = get_the_terms(get_the_ID(), 'portfolio_entries');
    $terms = array();
    if ( $portfolio_cat_slug && ! is_wp_error( $terms ) ) :
    foreach($portfolio_cat_slug as $term ) {
    $portfolio_cat[] = $term->name;
    }
    endif;
    $portfolio_cat = $portfolio_cat[0];

    $project_slug = $portfolio_cat;

    if ( !$project_slug ) { // remove project prefix
    return str_replace('%issue_project%', '', $post_link);
    }
    // put project slug in place of %issue_project%
    return str_replace('%issue_project%', 'portfolio/'.$project_slug, $post_link);
    }

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘portfolio url – how to get example.com/portfolio_category/subcategory/post_name’ is closed to new replies.