Support » Plugin: Custom Content Type Manager » [Plugin: Custom Content Type Manager] Display only logged in user's posts

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor fireproofsocks


    You could do that, but not with the shortcode. You’d need to use some PHP functions to get the id of the currently logged in user, and then pass that id as an argument to the GetPostsQuery::get_posts function. The shortcode can’t compete with PHP for functionality and customizations.

    I’m in the midst of things and have it working, and am still doing cleanup work. I’m on the steep end of the learning curve of the whold wp/php/query/template thing. So, swallow your coffee and set down your cup. Here is where I’m at with a template right now, which is a hack of stuff you’ve provided + a file from my theme + whatever else I’ve found online that makes sense:

    Like I said, I’m still cleaning things up, but this code does display a list of custom posts generated by the individual who is logged in.

    // Exit if accessed directly
    if ( !defined('ABSPATH')) exit;
     * Blog Template
       Template Name: Cards list all
     * @file           cards-list-all.php
     * @package        Responsive
     * @author         Emil Uzelac
     * @copyright      2003 - 2012 ThemeID
     * @license        license.txt
     * @version        Release: 1.0
     * @filesource     wp-content/themes/responsive/blog.php
     * @link 
     * @since          available since Release 1.0
    <?php get_header(); ?>
    <?php global $more; $more = 0; ?>
    <!--        <div id="content-blog" class="grid col-620"> -->
        if ( get_query_var('paged') )
    	    $paged = get_query_var('paged');
    	elseif ( get_query_var('page') )
    	    $paged = get_query_var('page');
    		$paged = 1;
     <?php query_posts( 'post_type=cards'); ?>
    <?php if (have_posts()) : ?>
    $theuser = get_current_user_id();
    echo ($theuser);
    		<?php while (have_posts()) : the_post(); ?>
    <?php  $theauthor = get_the_author_meta('id');  ?>
    <?php if ($theauthor == $theuser ) : ?>
    <tr><td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td><td><?php print_custom_field('tagC'); ?></td><td><?php print_custom_field('typeC'); ?></td><td><?php echo($theauthor); ?></td></tr>
    <?php endif; ?>
            <?php endwhile; ?> 
            <?php if (  $wp_query->max_num_pages > 1 ) : ?>
            <div class="navigation">
    			<div class="previous"><?php next_posts_link( __( '‹ Older posts', 'responsive' ) ); ?></div>
                <div class="next"><?php previous_posts_link( __( 'Newer posts ›', 'responsive' ) ); ?></div>
    		</div><!-- end of .navigation -->
            <?php endif; ?>
    	    <?php else : ?>
            <h1 class="title-404"><?php _e('404 — Fancy meeting you here!', 'responsive'); ?></h1>
            <p><?php _e('Don't panic, we'll get through this together. Let's explore our options here.', 'responsive'); ?></p>
            <h6><?php _e( 'You can return', 'responsive' ); ?> <a href="<?php echo home_url(); ?>/" title="<?php esc_attr_e( 'Home', 'responsive' ); ?>"><?php _e( '&larr; Home', 'responsive' ); ?></a> <?php _e( 'or search for the page you were looking for', 'responsive' ); ?></h6>
            <?php get_search_form(); ?>
    <?php endif; ?>
              </div><!-- end of #content-blog -->
    <?php wp_reset_query() ?>
    <?php get_footer(); ?>

    And thanks, again, for your Awesome plugin and for all your help.

    Plugin Contributor fireproofsocks


    Glad you found a solution!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Custom Content Type Manager] Display only logged in user's posts’ is closed to new replies.