• Hi, I need help changing the order in which my portfolio categories appear on my site. https://newpage.felipeascacibar.com/

    I have learnd that it is possible to:
    'orderby' => 'slug',
    changing the code in “portfolio.php”
    but the theme I’m using doesn’t have a
    portfolio.php!?
    I found some code in “theme_actions.php” but I cant figure out how to make it sort by slugs. Please Help!

    /*
     * Displays the isotope filters for the portfolio
     */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter">
    
    <li><a href="#"></a></li>
    ';
    
    	$categories = get_categories('taxonomy=portfolio-category');
    	foreach ($categories as $category){
    		$output .= '
    
    <li><a href="#">slug . '">' . $category->name . '</a></li>
    ';
    	}
    
    	$output .= '';
    	echo $output;
    }
    /*

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Fxam

    (@fxam)

    Moderator bcworkz

    (@bcworkz)

    Assuming the code using get_categories() is the categories you wish to order by slug (it looks to be the case, but I’m not 100% sure), first re-format the taxonomy argument into array format. WP developers are trying to move away from string format in favor of array format. Then just add the order by slug argument to the array. You end up with this:

    $categories = get_categories( array(
       'taxonomy' => 'portfolio-category',
       'orderby' => 'slug',
    ));

    After this, go right into the foreeach loop.

    Thread Starter Fxam

    (@fxam)

    Thanks! Unfortunately there is still a problem?

    */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter"><li><a class="active" href="#" data-filter="*"></a></li>';
    	$categories = get_categories( array(
       	'taxonomy' => 'portfolio-category',
       	'orderby' => 'slug',));
    	foreach ($categories as $category){
    	$output .= '<li><a href="#" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
    	}
    
    	$output .= '</ul>';
    	echo $output;
    }
    
    /*
    Thread Starter Fxam

    (@fxam)

    I also tried:

    */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter"><li><a class="active" href="#" data-filter="*"></a></li>';
    	$categories = get_categories( array(
       	'taxonomy' => 'portfolio-category',
       	'orderby' => 'slug',
    ));
    	foreach ($categories as $category){
    	$output .= '<li><a href="#" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
    	}
    
    	$output .= '</ul>';
    	echo $output;
    }
    
    /*

    Thread Starter Fxam

    (@fxam)

    damm! now I have really messed it up ??

    Ahhhhhhhhhh…. cant undo???

    Thread Starter Fxam

    (@fxam)

    Parse error: syntax error, unexpected ‘}’ in /homepages/8/d39654049/htdocs/wp_felipe/wp-content/themes/marble/ebor_framework/theme_actions.php on line 80

    Thread Starter Fxam

    (@fxam)

    line 80 is:

    if( get_post_meta( $post->ID, '_cmb_the_client_date', true ) && get_option('portfolio_date', '1') == 1 ){

    Moderator bcworkz

    (@bcworkz)

    Undo? That would be nice. I take it you are using the built in editor of WP? While it is very handy for doing quick edits, it is a dangerous tool due to the lack of undo and inability to maintain incremental back ups. Even though it is more trouble, I recommend moving files by FTP and editing them with a syntax highlighting programmer’s editor.

    (Even better is a locally installed test installation, but this can be time consuming to set up)

    I don’t see any syntax errors in the code you posted, sometimes the error is actually above the line reported by PHP. You probably have mismatched curly braces somewhere. If you download the file and open it in an editor that has bracket matching, it shouldn’t be too hard to locate. If you can’t find the error, you may need to restore the file from your theme download or where ever it came from.

    Once that is fixed, if you’re still not getting what you want from the query, please describe what is happening and how it is not working for you. Just stating that there’s a problem doesn’t give me much to go on ??

    Thread Starter Fxam

    (@fxam)

    Hi BCW,
    yes I am using the built in WP editor. Thanks for your advice!

    I restored the file “theme_actions.php” from the theme download and now every thing is back the way it was.

    I am using a theme called Marble and I would like to change the order in which the portfolio isotope filters are displayed!

    In the theme the filters are displayed in alphabetical order by category as follows:
    ALL / ARCHIVE / COMMERCIAL / OTHER / SHOWREEL

    I believe to have found the original code that does this in theme_actions.php it looks like this:

    /*
     * Displays the isotope filters for the portfolio
     */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter"><li><a class="active" href="#" data-filter="*">'.__('All','marble').'</a></li>';
    
    	$categories = get_categories('taxonomy=portfolio-category');
    	foreach ($categories as $category){
    		$output .= '<li><a href="#" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
    	}
    
    	$output .= '</ul>';
    	echo $output;
    }
    
    /*

    Please see https://newpage.felipeascacibar.com/

    I would like the filters to be displayed as follows:
    SHOWREEL COMMERCIAL ARCHIVE OTHER

    I was able to remove the “/” between filters in the custom.css by adding:

    .fix-portfolio .filter li:after {
    	content: "";
    }

    and I removed the “ALL” portfolio filter which was displayed first in the theme by default by deleting it from theme_actions.php:

    */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter"><li><a class="active" href="#" data-filter="*">'.__('').'</a></li>';
    
    	$categories = get_categories('taxonomy=portfolio-category');
    	foreach ($categories as $category){
    		$output .= '<li><a href="#" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
    	}

    So far so good. It seems to work the way I would like it to! ?? Any remarks? Do you have any better Ideas so far?

    I read in a thread that it was possible to order the filters by slug so I gave SHOWREEL slug=1, COMMERCIAL slug=2, ARCHIVE slug=3 and OTHER slug=4.

    I tried to re-format the taxonomy argument into array format like you suggested and continued with the foreeach loop. Like this:

    */
    add_action( 'ebor_portfolio_filters', 'ebor_portfolio_filters_markup', 10 );
    function ebor_portfolio_filters_markup(){
    	$output = '';
    	$output = '<ul class="filter"><li><a class="active" href="#" data-filter="*"></a></li>';
    	$categories = get_categories( array(
       	'taxonomy' => 'portfolio-category',
       	'orderby' => 'slug',
    ));
    	foreach ($categories as $category){
    	$output .= '<li><a href="#" data-filter=".' . $category->slug . '">' . $category->name . '</a></li>';
    	}
    
    	$output .= '</ul>';
    	echo $output;
    }
    
    /*

    But after refreshing my browser all I get is and error message:

    Parse error: syntax error, unexpected ‘*’ in /homepages/8/d39654049/htdocs/wp_felipe/wp-content/themes/marble/ebor_framework/theme_actions.php on line 56

    And from there I have to restore the theme_actions.php from the theme download all over again. ??

    Any Idea what I am doing wrong?
    Thanks for your help I really appreciate it!!!
    Cheers, Fxam

    have you tried simply changing date of the single item?
    (it seems work if you set a previous date from the original)

    let me know

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Custom Order Portfolio Filters Marble Theme’ is closed to new replies.