Forum Replies Created

Viewing 15 replies - 1 through 15 (of 104 total)
  • Hey man,

    Thanks for your quick reply. I came [here] from here: http://ww.wp.xz.cn/support/topic/sub-categories-to-use-parent-category-template?replies=13

    I guess I’ll just have to persevere.

    Cheers,

    +1

    I’m using a custom post type (products). My products have child categories (I’ve called them product_types).

    My template structure:

    1. category-products.php
    2. loop-products.php
    3. single-products.php

    This plugin doesn’t appear to work? Am I doing something wrong?

    Thanks,

    Did you work out how to output your custom data into a page template?

    @gian-ava if you’re not using the plugin ( http://ww.wp.xz.cn/extend/plugins/wp-pagenavi/ ) this your solution isn’t a fix either.

    Ideally I’d like to resolve this without installing more plugins. It’s an issue with core.

    Thanks,

    After hours of experimentation this worked for me…

    The key is to ensure when you first register the post type that your post type name is different from your page (if you’re using a page template).

    This rule of thumb also applies if you’re using a plugin like: http://ww.wp.xz.cn/extend/plugins/custom-post-type-ui/ – check the code it outputs!

    My page is named ‘Products

    My post type is named ‘product‘:

    register_post_type('<strong>product</strong>', array(	'label' => 'Products','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => ''),'query_var' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'labels' => array (
      'name' => 'Products',
      'singular_name' => 'Product',
      'menu_name' => 'Products',
      'add_new' => 'Add Product',
      'add_new_item' => 'Add New Product',
      'edit' => 'Edit',
      'edit_item' => 'Edit Product',
      'new_item' => 'New Product',
      'view' => 'View Product',
      'view_item' => 'View Product',
      'search_items' => 'Search Products',
      'not_found' => 'No Products Found',
      'not_found_in_trash' => 'No Products Found in Trash',
      'parent' => 'Parent Product',
    ),) );

    You may find you have to gut your wp_posts for a clean slate, but this solution requires no additional slug rewrites.

    Best,

    After hours of experimentation this worked for me…

    The key is to ensure when you first register the post type that your post type name is different from your page (if you’re using a page template).

    This rule of thumb also applies if you’re using a plugin like: http://ww.wp.xz.cn/extend/plugins/custom-post-type-ui/ – check the code it outputs!

    My page is named ‘Products

    My post type is named ‘product‘:

    register_post_type('<strong>product</strong>', array(	'label' => 'Products','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => ''),'query_var' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'labels' => array (
      'name' => 'Products',
      'singular_name' => 'Product',
      'menu_name' => 'Products',
      'add_new' => 'Add Product',
      'add_new_item' => 'Add New Product',
      'edit' => 'Edit',
      'edit_item' => 'Edit Product',
      'new_item' => 'New Product',
      'view' => 'View Product',
      'view_item' => 'View Product',
      'search_items' => 'Search Products',
      'not_found' => 'No Products Found',
      'not_found_in_trash' => 'No Products Found in Trash',
      'parent' => 'Parent Product',
    ),) );

    You may find you have to gut your wp_posts for a clean slate, but this solution requires no additional slug rewrites.

    Best,

    Forgot to include my pagination links didn’t I – doh. All good. Bedtime!

    page-products.php

    <?php
    /*
    Template Name: Products
    */
    
    get_header(); ?>
    
    <div id="container">
    	<div id="content" role="main">
    
    		<?php query_posts(array('post_type'=>'products','posts_per_page'=>1,'paged'=>get_query_var('paged'))); ?>
    
    		<?php /* Display navigation to next/previous pages when applicable */ ?>
    		<?php if ( $wp_query->max_num_pages > 1 ) : ?>
    		<div id="nav-above" class="navigation">
    			<div class="nav-previous">
    				<?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?>
    			</div>
    			<div class="nav-next">
    				<?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    			</div>
    		</div>
    		<!-- #nav-above -->
    		<?php endif; ?>
    
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
    				<?php the_title(); ?>
    				</a></h2>
    			<div class="entry-meta">
    				<?php twentyten_posted_on(); ?>
    			</div>
    			<!-- .entry-meta -->
    			<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    			<div class="entry-summary">
    				<?php the_excerpt(); ?>
    			</div>
    			<!-- .entry-summary -->
    			<?php else : ?>
    			<div class="entry-content">
    				<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    			</div>
    			<!-- .entry-content -->
    			<?php endif; ?>
    			<div class="entry-utility">
    				<?php if ( count( get_the_category() ) ) : ?>
    				<span class="cat-links"> <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> </span> <span class="meta-sep">|</span>
    				<?php endif; ?>
    				<?php
    					$tags_list = get_the_tag_list( '', ', ' );
    					if ( $tags_list ):
    				?>
    				<span class="tag-links"> <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?> </span> <span class="meta-sep">|</span>
    				<?php endif; ?>
    				<span class="comments-link">
    				<?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
    				</span>
    				<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    			</div>
    			<!-- .entry-utility -->
    		</div>
    		<!-- #post-## -->
    		<?php comments_template( '', true ); ?>
    
    		<?php endwhile; // End the loop. Whew. ?>
    		<?php endif; ?>
    
    		<?php /* Display navigation to next/previous pages when applicable */ ?>
    		<?php if (  $wp_query->max_num_pages > 1 ) : ?>
    		<div id="nav-below" class="navigation">
    			<div class="nav-previous">
    				<?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?>
    			</div>
    			<div class="nav-next">
    				<?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    			</div>
    		</div>
    		<!-- #nav-below -->
    		<?php endif; ?>
    
    	</div>
    	<!-- #content -->
    </div>
    <!-- #container -->
    <?php // get_sidebar(); ?>
    <?php // get_footer(); ?>

    Many thanks,

    Here’s my code anyway:

    functions.php

    register_post_type('products', array(	'label' => 'Products','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => 'products'),'query_var' => true,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'labels' => array (
      'name' => 'Products',
      'singular_name' => 'Product',
      'menu_name' => 'Products',
      'add_new' => 'Add Product',
      'add_new_item' => 'Add New Product',
      'edit' => 'Edit',
      'edit_item' => 'Edit Product',
      'new_item' => 'New Product',
      'view' => 'View Product',
      'view_item' => 'View Product',
      'search_items' => 'Search Products',
      'not_found' => 'No Products Found',
      'not_found_in_trash' => 'No Products Found in Trash',
      'parent' => 'Parent Product',
    ),) );

    page-products.php

    <?php
    /*
    Template Name: Products
    */
    
    get_header(); ?>
    
    <div id="container">
    	<div id="content" role="main">
    
    		<?php query_posts(array('post_type'=>'products','posts_per_page'=>1,'paged'=>get_query_var('paged'))); ?>
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
    				<?php the_title(); ?>
    				</a></h2>
    			<div class="entry-meta">
    				<?php twentyten_posted_on(); ?>
    			</div>
    			<!-- .entry-meta -->
    			<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    			<div class="entry-summary">
    				<?php the_excerpt(); ?>
    			</div>
    			<!-- .entry-summary -->
    			<?php else : ?>
    			<div class="entry-content">
    				<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    			</div>
    			<!-- .entry-content -->
    			<?php endif; ?>
    			<div class="entry-utility">
    				<?php if ( count( get_the_category() ) ) : ?>
    				<span class="cat-links"> <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> </span> <span class="meta-sep">|</span>
    				<?php endif; ?>
    				<?php
    					$tags_list = get_the_tag_list( '', ', ' );
    					if ( $tags_list ):
    				?>
    				<span class="tag-links"> <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?> </span> <span class="meta-sep">|</span>
    				<?php endif; ?>
    				<span class="comments-link">
    				<?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?>
    				</span>
    				<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    			</div>
    			<!-- .entry-utility -->
    		</div>
    		<!-- #post-## -->
    		<?php comments_template( '', true ); ?>
    
    		<?php endwhile; // End the loop. Whew. ?>
    		<?php endif; ?>
    
    	</div>
    	<!-- #content -->
    </div>
    <!-- #container -->
    <?php // get_sidebar(); ?>
    <?php // get_footer(); ?>

    @fonglh would you mind posting your template page?

    My last comment was only half a solution to the problem. I’m still looking for a solution to pagination on a template page whilst querying for custom post types?

    If anyone finds a solution please drop a note in below.

    @fonglh I’ll assume you aren’t using a template page to query for your custom post types; using your index page instead?

    Thanks,

    Just solved this actually.

    register_post_type('products', array(
      'rewrite' => array('slug' => 'products')
    ));

    or alternatively if you’re using this plugin ( http://ww.wp.xz.cn/extend/plugins/custom-post-type-ui/ ) you’ll want to ensure under ‘Manage Post Types > Advanced Options’ that you provide a ‘Custom Rewrite Slug’.

    My URL now looks something like this, with the extra level clearing naming clashes up:

    http://localhost/project/products/product-1/

    Best,

    @curtiss Grymala cheers mate. Been after a simple answer to this question for about 12hrs. Surprising nobody in the #wordpress irc was capable :/

    Thread Starter ldexterldesign

    (@ldexterldesign)

    ‘Obviously you want to change to formatting of the plugin messages…’

    – yes, but I’ve HAD to detail the mark-up in order to hang my styles off it. It’s annoying for front-end developers, like myself, who use WordPress plug-ins, no less average users with basic CSS knowledge, to have to go into PHP to find and amend (sloppy) mark-up.

    ‘…but the code you’ve posted will put the message into italics for all users’

    – true, but remember the primary importance of HTML is meaning, not styling.

    Not only does <em> provide the correct meaning (emphasis) to any validation errors/flags/ or notifications IMO, it also has the added benefit of providing a more granular marker to hang styles off.

    I would consider any of the following ‘correct’ alternatives, but some marker would be better than nothing!:

    <p><span class="notify flag error youGetTheIdea">That email address is not subscribed.</span></p>
    <p class="notify flag error youGetTheIdea">That email address is not subscribed.</p>

    Thanks for your email Matt. I hope this is a suitable explanation.

    Best,

    Thread Starter ldexterldesign

    (@ldexterldesign)

    Fix: http://ldexterldesign.posterous.com/3629-lines-in-my-true-love-gave-to-me-ruinede

    Is there a more specific filter I can use here just for K2 in this instance?

    Is this post related: http://ww.wp.xz.cn/support/topic/add_filter-to-the_title-only-in-wp_nav_menu ?

    Thanks,

Viewing 15 replies - 1 through 15 (of 104 total)