Wsparcie » Motywy » Pytheas – narzucona kategoria portfolio

  • Se3a

    (@se3a)


    Witam 🙂

    Korzystam z ów motywu > https://justfreethemes.com/pytheas-free-wordpress-theme/

    Mam problem jednak ponieważ sam moduł/skrypt portfolio mi się podoba jednak przy tworzeniu w nim artykułu narzuca w adresie swoją kategorię czyli http://www.mojastrona/portfolio/nazwaarta.

    Chciałbym żeby tak zmienić to w kodzie aby nie było tego portfolio tylko po prostu http://www.mojastrona/nazwaarta.

    Poniżej taxonomy-portfolio_category.php

    <?php
    /**
     * The template for displaying Portfolio Categories
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package   Pytheas WordPress Theme
     * @author    Alexander Clarke
     * @copyright Copyright (c) 2015, WPExplorer.com
     * @link      http://www.wpexplorer.com
     * @since     1.0.0
     */
    
    get_header(); ?>
    
    	<header class="page-header clr">
    		<h1 class="page-header-title"><?php echo single_term_title(); ?
    
    ></h1>
    		<?php if ( category_description() ) : ?>
    			<div class="archive-meta"><?php echo term_description(); ?
    
    ></div>
    		<?php endif; ?>
    		<?php if ( wpex_get_option( 'portfolio_archive_filter', '1' ) ) : ?>
    			<?php $posttype_obj = get_post_type_object( 'portfolio' ); 
    
    ?>
    			<?php $portfolio_terms = get_terms( 'portfolio_category', 
    
    array( 'orderby' => 'koncert', 'order' => 'ASC' ) ); ?>
    			<?php if ( $portfolio_terms ) : ?>
    				<ul class="tax-archives-filter dropdown-menu clr">
    				<li class="browse"><a href="#" title="<?php _e( 
    
    'Browse', 'pytheas' ); ?>"><?php _e( 'Browse', 'pytheas' ); ?> <?php echo 
    
    $posttype_obj->label; ?><i class="fa fa-caret-down"></i></a>
    						<ul>
    							<li><a href="<?php echo 
    
    get_post_type_archive_link( 'koncert' ); ?>" title="<?php echo $posttype_obj-
    
    >label; ?>" class="active"><?php _e( 'All', 'pytheas' ); ?></a></li>
    							<?php foreach( 
    
    $portfolio_terms as $portfolio_term ) : ?>
    								<li><a href="<?php 
    
    echo esc_url( get_term_link( $portfolio_term->slug, 'portfolio_category' ) ); ?>" 
    
    title="<?php echo esc_attr( $portfolio_term->name ); ?>"><?php echo esc_html( 
    
    $portfolio_term->name ); ?></a></li>
    							<?php endforeach; ?>
    						</ul>
    					</li>
    				</ul><!-- .tax-archives-filter -->
    			<?php endif; ?>
    		<?php endif; ?>
    	</header><!-- .page-heading -->
    
    	<?php if ( have_posts( ) ) : ?>
    		<div id="primary" class="content-area span_24 row clr">
    			<div id="content" class="site-content" role="main">
    				<div class="portfolio-content row clr">
    					<?php
    					$wpex_count=0;
    					while ( have_posts() ) : the_post();
    						$wpex_count++;
    						get_template_part( 'content', 
    
    'portfolio' );
    						if ( $wpex_count == 4 ) {
    							echo '<div 
    
    class="clr"></div>';
    							$wpex_count=0;
    						}
    					endwhile; ?>
    				</div><!-- .portfolio-content -->
    				<?php wpex_pagination(); ?>
    			</div><!-- #content -->
    		</div><!-- #primary -->
    	<?php endif; ?>
    
    <?php get_footer(); ?>

    oraz portfolio.php

    <?php
    if ( ! class_exists( 'Symple_Portfolio_Post_Type' ) ) :
    	class Symple_Portfolio_Post_Type {
    
    		public function __construct() {
    
    			// Adds the portfolio post type and taxonomies
    			add_action( 'init', array( &$this, 'portfolio_init' ), 0 );
    
    			// Thumbnail support for portfolio posts
    			add_theme_support( 'post-thumbnails', array( 'portfolio' ) );
    
    			// Adds columns in the admin view for thumbnail and taxonomies
    			add_filter( 'manage_edit-portfolio_columns', array( &$this, 'portfolio_edit_columns' ) );
    			add_action( 'manage_portfolio_posts_custom_column', array( &$this, 'portfolio_column_display' ), 10, 2 );
    
    			// Allows filtering of posts by taxonomy in the admin view
    			add_action( 'restrict_manage_posts', array( &$this, 'portfolio_add_taxonomy_filters' ) );
    
    		}
    
    		public function portfolio_init() {
    			$labels = array(
    				'name'					=> __( 'Portfolio', 'pytheas' ),
    				'singular_name'			=> __( 'Portfolio Item', 'pytheas' ),
    				'add_new'				=> __( 'Add New Item', 'pytheas' ),
    				'add_new_item'			=> __( 'Add New Portfolio Item', 'pytheas' ),
    				'edit_item'				=> __( 'Edit Portfolio Item', 'pytheas' ),
    				'new_item'				=> __( 'Add New Portfolio Item', 'pytheas' ),
    				'view_item'				=> __( 'View Item', 'pytheas' ),
    				'search_items'			=> __( 'Search Portfolio', 'pytheas' ),
    				'not_found'				=> __( 'No portfolio items found', 'pytheas' ),
    				'not_found_in_trash'	=> __( 'No portfolio items found in trash', 'pytheas' )
    			);
    			
    			$args = array(
    				'labels'			=> $labels,
    				'public'			=> true,
    				'supports'			=> array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'revisions', 'post-formats' ),
    				'capability_type'	=> 'post',
    				'rewrite'			=> array( "slug" => "portfolio" ), // Permalinks format
    				'has_archive'		=> true,
    				'menu_icon'			=> 'dashicons-portfolio',
    			); 
    			
    			$args = apply_filters('symple_portfolio_args', $args);
    			
    			register_post_type( 'portfolio', $args );
    
    			$taxonomy_portfolio_tag_labels = array(
    				'name'							=> __( 'Portfolio Tags', 'pytheas' ),
    				'singular_name'					=> __( 'Portfolio Tag', 'pytheas' ),
    				'search_items'					=> __( 'Search Portfolio Tags', 'pytheas' ),
    				'popular_items'					=> __( 'Popular Portfolio Tags', 'pytheas' ),
    				'all_items'						=> __( 'All Portfolio Tags', 'pytheas' ),
    				'parent_item'					=> __( 'Parent Portfolio Tag', 'pytheas' ),
    				'parent_item_colon'				=> __( 'Parent Portfolio Tag:', 'pytheas' ),
    				'edit_item'						=> __( 'Edit Portfolio Tag', 'pytheas' ),
    				'update_item'					=> __( 'Update Portfolio Tag', 'pytheas' ),
    				'add_new_item'					=> __( 'Add New Portfolio Tag', 'pytheas' ),
    				'new_item_name'					=> __( 'New Portfolio Tag Name', 'pytheas' ),
    				'separate_items_with_commas'	=> __( 'Separate portfolio tags with commas', 'pytheas' ),
    				'add_or_remove_items'			=> __( 'Add or remove portfolio tags', 'pytheas' ),
    				'choose_from_most_used'			=> __( 'Choose from the most used portfolio tags', 'pytheas' ),
    				'menu_name'						=> __( 'Portfolio Tags', 'pytheas' )
    			);
    
    			$taxonomy_portfolio_tag_args = array(
    				'labels'				=> $taxonomy_portfolio_tag_labels,
    				'public'				=> true,
    				'show_in_nav_menus'		=> true,
    				'show_ui'				=> true,
    				'show_tagcloud'			=> true,
    				'hierarchical'			=> false,
    				'rewrite'				=> array( 'slug'	=> 'portfolio-tag' ),
    				'query_var'				=> true
    			);
    
    			$taxonomy_portfolio_tag_args = apply_filters('symple_taxonomy_portfolio_tag_args', $taxonomy_portfolio_tag_args);
    			
    			register_taxonomy( 'portfolio_tag', array( 'portfolio' ), $taxonomy_portfolio_tag_args );
    
    			$taxonomy_portfolio_category_labels = array(
    				'name'							=> __( 'Portfolio Categories', 'pytheas' ),
    				'singular_name'					> __( 'Portfolio Category', 'pytheas' ),
    				'search_items'					=> __( 'Search Portfolio Categories', 'pytheas' ),
    				'popular_items'					=> __( 'Popular Portfolio Categories', 'pytheas' ),
    				'all_items'						=> __( 'All Portfolio Categories', 'pytheas' ),
    				'parent_item'					=> __( 'Parent Portfolio Category', 'pytheas' ),
    				'parent_item_colon'				=> __( 'Parent Portfolio Category:', 'pytheas' ),
    				'edit_item'						=> __( 'Edit Portfolio Category', 'pytheas' ),
    				'update_item'					=> __( 'Update Portfolio Category', 'pytheas' ),
    				'add_new_item'					=> __( 'Add New Portfolio Category', 'pytheas' ),
    				'new_item_name'					=> __( 'New Portfolio Category Name', 'pytheas' ),
    				'separate_items_with_commas'	=> __( 'Separate portfolio categories with commas', 'pytheas' ),
    				'add_or_remove_items'			=> __( 'Add or remove portfolio categories', 'pytheas' ),
    				'choose_from_most_used'			=> __( 'Choose from the most used portfolio categories', 'pytheas' ),
    				'menu_name'						=> __( 'Portfolio Categories', 'pytheas' ),
    			);
    
    			$taxonomy_portfolio_category_args = array(
    				'labels'				=> $taxonomy_portfolio_category_labels,
    				'public'				=> true,
    				'show_in_nav_menus'		=> true,
    				'show_ui'				=> true,
    				'show_tagcloud'			=> true,
    				'hierarchical'			=> true,
    				'rewrite'				=> array( 'slug'	=> 'portfolio-category' ),
    				'query_var'				=> true,
    			);
    
    			$taxonomy_portfolio_category_args = apply_filters('symple_taxonomy_portfolio_category_args', $taxonomy_portfolio_category_args);
    			
    			register_taxonomy( 'portfolio_category', array( 'portfolio' ), $taxonomy_portfolio_category_args );
    
    		}
    
    		public function portfolio_edit_columns( $columns ) {
    			$columns['portfolio_category'] = __( 'Category', 'pytheas' );
    			$columns['portfolio_tag'] = __( 'Tags', 'pytheas' );
    			return $columns;
    		}
    
    		public function portfolio_column_display( $column, $post_id ) {
    
    			// Code from: http://wpengineer.com/display-post-thumbnail-post-page-overview
    
    			switch ( $column ) {
    
    				// Display the thumbnail in the column view
    				case "portfolio_thumbnail":
    					$width = (int) 80;
    					$height = (int) 80;
    					$thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
    
    					// Display the featured image in the column view if possible
    					if ( $thumbnail_id ) {
    						$thumb = wp_get_attachment_image( $thumbnail_id, array($width, $height), true );
    					}
    					if ( isset( $thumb ) ) {
    						echo $thumb;
    					} else {
    						echo __('None', 'pytheas');
    					}
    					break;
    
    				// Display the portfolio tags in the column view
    				case "portfolio_category":
    
    				if ( $category_list = get_the_term_list( $post_id, 'portfolio_category', '', ', ', '' ) ) {
    					echo $category_list;
    				} else {
    					echo __('None', 'pytheas');
    				}
    				break;	
    
    				// Display the portfolio tags in the column view
    				case "portfolio_tag":
    
    				if ( $tag_list = get_the_term_list( $post_id, 'portfolio_tag', '', ', ', '' ) ) {
    					echo $tag_list;
    				} else {
    					echo __('None', 'pytheas');
    				}
    				break;
    			}
    		}
    
    		public function portfolio_add_taxonomy_filters() {
    			global $typenow;
    
    			// An array of all the taxonomyies you want to display. Use the taxonomy name or slug
    			$taxonomies = array( 'portfolio_category', 'portfolio_tag' );
    
    			// must set this to the post type you want the filter(s) displayed on
    			if ( $typenow == 'portfolio' ) {
    
    				foreach ( $taxonomies as $tax_slug ) {
    					$current_tax_slug = isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : false;
    					$tax_obj = get_taxonomy( $tax_slug );
    					$tax_name = $tax_obj->labels->name;
    					$terms = get_terms($tax_slug);
    					if ( count( $terms ) > 0) {
    						echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
    						echo "<option value=''>$tax_name</option>";
    						foreach ( $terms as $term ) {
    							echo '<option value=' . $term->slug, $current_tax_slug == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
    						}
    						echo "</select>";
    					}
    				}
    			}
    		}
    
    	}
    
    	new Symple_Portfolio_Post_Type;
    
    endif;

    Dziękuję z góry za pomoc 🙂

    • This topic was modified 7 years temu by Se3a.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Paweł

    (@mrpauloen)

    Pytanie tylko, którego z typu postów uzywasz?

    Nawet jeżeli utworzysz nowy typ postu czyli portfolio, domyślny czyli post_type=post nadal pozostaje i mozna tworzyć wpisy zwykle i te dla portfolio.

    Powinieneś mieć wtedy w Panelu zakładkę: Wpisy, Strony, Portfolio… itd.

    Natomias za ten nietypowy URL jest odpowiedzialny argument:
    rewrite

    Należy przypisać mu wartość: false

    Więcej znajdziesz w dokumentacji:
    https://codex.wordpress.org/Function_Reference/register_taxonomy

    Thread Starter Se3a

    (@se3a)

    Ja rozumiem tylko właśnie chodzi o to że w Portfolio tworzysz (add new item) i nie tworzy się go ani w Wpisach ani w Stronie tylko własnie w Portfolio 🙂 I potem jest ładny układ na stronie głównej ale link pozostaje ten co ci podałem. Okej z tym rewrite coś słyszałem, pokombinuję jeszcze, dzia w razie co się odezwę 🙂

    Thread Starter Se3a

    (@se3a)

    $taxonomy_portfolio_category_args = array(
    'labels’ => $taxonomy_portfolio_category_labels,
    'public’ => false,
    'show_in_nav_menus’ => false,
    'show_ui’ => false,
    'show_tagcloud’ => false,
    'hierarchical’ => false,
    'rewrite’ => array( 'slug’ => 'portfolio_category’ ),
    'query_var’ => false,

    więc mam coś takiego i co tutaj podmienić bo samo wywalenie potrfolio_category nic nie daje i jak daję false zamiast array to stronka się sypie 🙂

    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    Thread Starter Se3a

    (@se3a)

    $taxonomy_portfolio_tag_args = array(
    				'labels'				=> $taxonomy_portfolio_tag_labels,
    				'public'				=> true,
    				'show_in_nav_menus'		=> true,
    				'show_ui'				=> true,
    				'show_tagcloud'			=> true,
    				'hierarchical'			=> false,
    				'rewrite'				=> array( 'slug'	=> 'portfolio-tag' ),
    				'query_var'				=> true
    $taxonomy_portfolio_category_args = array(
    				'labels'				=> $taxonomy_portfolio_category_labels,
    				'public'				=> true,
    				'show_in_nav_menus'		=> true,
    				'show_ui'				=> true,
    				'show_tagcloud'			=> true,
    				'hierarchical'			=> true,
    				'rewrite'				=> array( 'slug'	=> 'portfolio-category' ),
    				'query_var'				=> true,

    Tak wygląda oryginalny kod bez żadnych zmian. Proszę o twoją edycję tak jak powinno to wyglądać 🙂 Dzięki i pozdrawiam!

    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    Paweł

    (@mrpauloen)

    ’rewrite’ => false,

    Thread Starter Se3a

    (@se3a)

    Po wykonaniu tego czyli jest tak>

    $taxonomy_portfolio_category_args = array(
    				'labels'				=> $taxonomy_portfolio_category_labels,
    				'public'				=> true,
    				'show_in_nav_menus'		=> true,
    				'show_ui'				=> true,
    				'show_tagcloud'			=> true,
    				'hierarchical'			=> true,
    				'rewrite'				=> false,
    				'query_var'				=> true,

    nadal mam narzucaną kategorię look

    Tutaj cały plik portfolio.php > https://megawrzuta.pl/download/5e9bb3665db85ee72e06de4ea3027696.html

    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    Paweł

    (@mrpauloen)

    To rewrite należy zmienić wszędzie a szczególnie w public function portfolio_init()

    Spróbuj też tak:

    'rewrite' => array(
     'slug'	=> false,
     'hierarchical' => false,
     ),
    Thread Starter Se3a

    (@se3a)

    'rewrite' => array(
     'slug'	=> false,
     'hierarchical' => false,
     ), 

    to nie pomaga, natomiast po zmianie przy każdym rewrite na false przy tworzeniu wychodzi taki link

    http://www.mojadres/?portfolio=nazwaarta

    i kurde tego nie potrzebuje 😛 ?portfolio=

    Ciężki przypadek ale mam nadzieję że wspólnie coś wywalczymy 😉

    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    • Ta odpowiedź została zmodyfikowana 7 years temu przez Se3a.
    Thread Starter Se3a

    (@se3a)

    public function portfolio_init() {
    			$labels = array(
    				'name'					=> __( 'Portfolio', 'pytheas' ),
    				'singular_name'			=> __( 'Portfolio Item', 'pytheas' ),
    				'add_new'				=> __( 'Add New Item', 'pytheas' ),
    				'add_new_item'			=> __( 'Add New Portfolio Item', 'pytheas' ),
    				'edit_item'				=> __( 'Edit Portfolio Item', 'pytheas' ),
    				'new_item'				=> __( 'Add New Portfolio Item', 'pytheas' ),
    				'view_item'				=> __( 'View Item', 'pytheas' ),
    				'search_items'			=> __( 'Search Portfolio', 'pytheas' ),
    				'not_found'				=> __( 'No portfolio items found', 'pytheas' ),
    				'not_found_in_trash'	=> __( 'No portfolio items found in trash', 'pytheas' )
    			);
    			
    			$args = array(
    				'labels'			=> $labels,
    				'public'			=> true,
    				'supports'			=> array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'revisions', 'post-formats' ),
    				'capability_type'	=> 'post',
    				'rewrite'			=> array( "slug" => "portfolio" ), // Permalinks format
    				'has_archive'		=> true,
    				'menu_icon'			=> 'dashicons-portfolio',
    			); 

    Po wielu zabawach rozwiązałem problem.

    Zostawiłem wszystko jak było a w tej linijce:

    'rewrite’ => array( „slug” => „koncert” ), // Permalinks format

    Zmieniłem z portfolio na koncert bo potrzebowałem akurat takiego przedrostka i pomogło 🙂

    Zatem można również usunąć stamtąd treść i nic nie powstanie 🙂

    Reszta rewrite akurat przy tym post_type może zostać bez zmian czyli array bez false.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Temat ‘Pytheas – narzucona kategoria portfolio’ jest zamknięty na nowe odpowiedzi.