Change Portfolio slug
-
Is it possible to change Portfolio to Activity in slug?
If so, I would be very grateful!The page I need help with: [log in to see the link]
-
Hello,
You would need to use a child theme and add this function to the child theme’s functions.php file:
add_filter( 'kadence_portfolio_permalink_slug', 'custom_portfolio_slug'); function custom_portfolio_slug() { return 'YOUR_CUSTOM_SLUG_HERE'; }
If you need to download a child theme, you can do so here:
https://www.kadencethemes.com/child-themes/-Kevin
Unfortunately, it doesn’t work for me.
Did you successfully activate the child theme with the function inside it?
Try going to Settings> Permalinks, and resave them.
-Kevin
I hope I activated child theme successfully. Otherwise, there are no changes in parent theme as well when changing functions.php and resaving permalinks.
There is portfolio function created. Perhaps, it’s possible to change something there?
<?php
function enlightenment_project_types( $args = null ) {
if ( ‘jetpack-portfolio’ != get_post_type() ) {
return;
}$defaults = array(
‘container’ => ‘span’,
‘container_class’ => ‘project-types’,
‘before’ => ”,
‘after’ => ”,
‘format’ => ‘%s’,
‘sep’ => ‘, ‘,
‘echo’ => true,
);
$defaults = apply_filters( ‘enlightenment_project_types_args’, $defaults );
$args = wp_parse_args( $args, $defaults );$output = ”;
$project_types = get_the_term_list( get_the_ID(), ‘jetpack-portfolio-type’, $args[‘before’], $args[‘sep’], $args[‘after’] );
if( ! empty( $project_types ) ) {
$output .= enlightenment_open_tag( $args[‘container’], $args[‘container_class’] );
$output .= $args[‘before’];
$output .= sprintf( $args[‘format’], $project_types );
$output .= $args[‘after’];
$output .= enlightenment_close_tag( $args[‘container’] );
}
$output = apply_filters( ‘enlightenment_project_types’, $output, $args );if( ! $args[‘echo’] ) {
return $output;
}echo $output;
}function enlightenment_project_types_filter( $args = null ) {
$args = array(
‘container’ => ‘ul’,
‘container_class’ => ‘project-types-filter’,
‘term_tag’ => ‘li’,
‘term_class’ => ‘project-type’,
‘current_term_class’ => ‘current-project-type’,
‘sep’ => ”,
‘echo’ => true,
);
$args = apply_filters( ‘enlightenment_project_types_filter_args’, $args );$terms = get_terms( ‘jetpack-portfolio-type’ );
$output = ”;
if( ! empty( $terms ) ) {
$output .= enlightenment_open_tag( $args[‘container’], $args[‘container_class’] );
if( is_tax( ‘jetpack-portfolio-type’ ) ) {
$output .= enlightenment_open_tag( $args[‘term_tag’], $args[‘term_class’] );
$output .= sprintf( ‘%3$s‘, get_post_type_archive_link( ‘jetpack-portfolio’ ), ‘jetpack-portfolio-type’, __( ‘All’, ‘enlightenment’ ) );
$output .= enlightenment_close_tag( $args[‘term_tag’] );
}
foreach( $terms as $term ) {
$class = $args[‘term_class’];
$link = get_term_link( $term, $term->taxonomy );
$current_url = sprintf( ‘%1$s%2$s%3$s’, is_ssl() ? ‘https://’ : ‘https://’, $_SERVER[‘HTTP_HOST’], $_SERVER[‘REQUEST_URI’] );
if( $link == $current_url ) {
$class .= ‘ ‘ . $args[‘current_term_class’];
}
$output .= enlightenment_open_tag( $args[‘term_tag’], $class );
$output .= sprintf( ‘%3$s‘, $link, $term->taxonomy, $term->name );
$output .= enlightenment_close_tag( $args[‘term_tag’] );
}
$output .= enlightenment_close_tag( $args[‘container’] );
}$output = apply_filters( ‘enlightenment_project_types_filter’, $output );
if( ! $args[‘echo’] )
return $output;
echo $output;
}add_filter( ‘enlightenment_archive_grids’, ‘enlightenment_portfolio_archive_grid’ );
function enlightenment_portfolio_archive_grid( $grids ) {
$grids[‘jetpack-portfolio’] = array(
‘grid’ => ‘threecol’,
‘lead_posts’ => 0,
);
$grids[‘jetpack-portfolio-type’] = array(
‘grid’ => ‘threecol’,
‘lead_posts’ => 0,
);
$grids[‘jetpack-portfolio-tag’] = array(
‘grid’ => ‘threecol’,
‘lead_posts’ => 0,
);
return $grids;
}add_filter( ‘enlightenment_content_hooks’, ‘enlightenment_portfolio_content_hooks’ );
function enlightenment_portfolio_content_hooks( $hooks ) {
$hooks[‘enlightenment_content’][‘functions’][] = ‘enlightenment_project_types_filter’;
return $hooks;
}add_filter( ‘enlightenment_template_functions’, ‘enlightenment_portfolio_template_functions’ );
function enlightenment_portfolio_template_functions( $functions ) {
$functions[‘enlightenment_project_types_filter’] = __( ‘Project Types Filter’, ‘enlightenment’ );
return $functions;
}- This reply was modified 6 years, 9 months ago by oleksiy365.
No, you should not edit that file. Only edit files in the child theme. In the downloaded child theme from the link I send you, add the function above to the functions.php file. There shouldn’t be anything else in this file when you download the child theme.
In Appearance> Themes, activate the child theme. Once the child theme is activated, go to Settings> Permalinks, and resave the permalinks.
does that make sense?
-Kevin
Kevin, thank you for your help!
I was playing around a lot and got no results.
So I decided to create custom post type. That was much easier.Thanks again.
Ah I see. I think there was a bit of a misunderstanding. Glad you figured it out though!
-Kevin
- The topic ‘Change Portfolio slug’ is closed to new replies.