WordPress.org

Ready to get started?Download WordPress

Forums

Page2cat: Category, Pages & Posts Shortcodes
[resolved] How to place this plugin in my theme ? (7 posts)

  1. sergio93
    Member
    Posted 1 year ago #

    Seems great plugin ;-)
    In which file of my theme (Twenty eleven modified) directory do i have to insert this code ?

    <?php do_shortcode('[showsingle pageid="<id_of_page>"]'); ?>

    http://wordpress.org/extend/plugins/page2cat/

  2. swergroup
    Member
    Plugin Author

    Posted 1 year ago #

    You can use that code in any template you like - for example in sidebars or before/after main content. You just need to avoid using the shortcode in the main loop: everything else is up to you.

    Let's say you have a template like this:

    <div id="content">
       [your main loop]
    </div>
    <div id="sidebar">
       [sidebar code]
    </div>

    You can use the shortcode above everything like that:

    <?php do_shortcode('[showsingle ...]'); ?>
    <div id="content">
       [your main loop]
    </div>
    <div id="sidebar">
       [sidebar code]
    </div>

    This will also work for the Category->Page binding, only if in the category.php files:

    <?php do_shortcode('[showauto]'); ?>
    <div id="content">
       [your main loop]
    </div>
    <div id="sidebar">
       [sidebar code]
    </div>

    Otherwise you can use it in your sidebar, maybe using the [showlist] shortcode:

    <div id="content">
       [your main loop]
    </div>
    <div id="sidebar">
    <?php do_shortcode('[showlist ...]'); ?>
       [sidebar code]
    </div>

    Hope it helps!

  3. sergio93
    Member
    Posted 1 year ago #

    Thank's. It works perfect when I associate a page to a category but not when I try to associate a specific post to a single category. The post is displayed in the whole pages, the homepage included. May be is the normal way to use your plugin ?

    Anyway, is a good work ;-)

  4. swergroup
    Member
    Plugin Author

    Posted 1 year ago #

    We're sorry but the exclusive link works only with pages, not posts.

  5. aski71
    Member
    Posted 1 year ago #

    Hi,
    I struggle with this and searched through various forums but somehow I seem to be to stupid to get this up and running.
    I'm using the Pinboard theme of one designs and I'm able to create a page that contains articles of a certain category by hardcoding the category id into on of the theme's templates. This is how it looks:

    <?php
    /*
    Template Name: #newsletter
    */
    ?><?php get_header(); ?>
    	<?php global $pinboard_page_template; ?>
    	<?php $pinboard_page_template = 'template-blog.php'; ?>
    	<?php if( pinboard_get_option( 'location' ) ) : ?>
    		<?php pinboard_current_location(); ?>
    	<?php endif; ?>
    	<div id="container">
    		<section id="content" class="column twothirdcol">
    			<?php $args = array( 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => max( 1, get_query_var( 'paged' ) ) ); ?>
    			<?php if( pinboard_get_option( 'blog_exclude_portfolio' ) ) : ?>
    				<?php $args['cat'] = '26'; ?>
    			<?php endif; ?>
    			<?php global $wp_query, $wp_the_query; ?>
    			<?php $wp_query = new WP_Query( $args ); ?>
    			<?php if( $wp_query->have_posts() ) : ?>
    				<div class="entries">
    					<?php while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    						<?php get_template_part( 'content', get_post_format() ); ?>
    					<?php endwhile; ?>
    				</div><!-- .entries -->
    				<?php pinboard_posts_nav(); ?>
    			<?php else : ?>
    				<?php pinboard_404(); ?>
    			<?php endif; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php $wp_query = $wp_the_query; ?>
    		</section><!-- #content -->
    		<?php get_sidebar(); ?>
    		<div class="clear"></div>
    	</div><!-- #container -->
    <?php get_footer(); ?>

    How do I now manage to use [showauto] with this template to be able to select different categories for different pages using this template?

    Thans!

  6. swergroup
    Member
    Plugin Author

    Posted 1 year ago #

    Hi aski71, [showauto] relies on the global $cat, so you have to overwrite it before calling the shortcode.

  7. swergroup
    Member
    Plugin Author

    Posted 1 year ago #

    Waiting for WP 3.6 and our new page2cat release, you can find better documentation (with usage examples and screenshots) on:

    http://dev.swergroup.com/pages-and-posts-shortcodes/wiki/Home

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.