WordPress.org

Ready to get started?Download WordPress

Forums

in custom posts (12 posts)

  1. EveVaterlaus
    Member
    Posted 1 year ago #

    How can I make the <!--more--> tag in my custom posts work exactly the way it does in regular posts?

    Site under construction:

    http://mindfulbirthny.com/wp/articles-by-mary-esther/ is custom posts page,

    http://mindfulbirthny.com/wp/birth-stories/ is regular posts page

    THANK YOU VERY MUCH!!

    Eve

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    I don't see any significant difference between the behaviour of the 'more tags' in the two linked post pages.

    can you describe in more detail what you consider to be different?

    you might need to provide the code of the two templates.

  3. EveVaterlaus
    Member
    Posted 1 year ago #

    In the birth stories page the 'more tag' opens a single post page, in the articles page the 'more tag just expands each post on the same page, so when the page is fully filled with many articles it will become unmanageably enormous. The 'Birth Stories" template is just the index.php, the articles page works with this .
    (thanks)

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <?php
    /**
     * Template Name: ARTICLES-2-PAGE*/ 
    
     get_header(); ?>
      	<!-- section -->
    	<section role="main">
    
    	  		 <h1><?php the_title(); ?></h1>
    			<?php query_posts( 'post_type=articles'); ?>
    			<?php if (have_posts()): while (have_posts()) : the_post(); ?>
    				<!-- article -->
    				<article id="post-<?php the_ID(); ?>"
    <?php post_class("MEMarticlePost"); ?>>
    				  <!-- post title -->
    				  <!-- post thumbnail -->
    					<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
    						<a>" title="<?php the_title(); ?>">
    							<?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
    						</a>
    					<?php endif; ?>
    					<!-- /post thumbnail -->
    					<!-- post title -->
    					<h2>
    						<a>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    					</h2>
    					  <?php
    					global $more;
    					$more = 0;
    					?>
    					<?php the_content(); ?>
    					<?php comments_template( '', true ); // Remove if you don't want comments ?>
    					<br class="clear">
    					<?php edit_post_link(); ?>
    				</article>
    				<!-- /article -->
    			<?php endwhile; ?>
    			<?php else: ?>
    				<!-- article -->
    				<article>
    					<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
    				</article>
    
    			<?php endif; ?>
    
    			</section>
    				<?php get_sidebar(); ?>
    		<?php get_footer(); ?>
  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    does your theme have a single-articles.php and if, what is the code?

    http://codex.wordpress.org/Template_Hierarchy#Single_Post_display

  5. EveVaterlaus
    Member
    Posted 1 year ago #

    yes, it does:

    <?php get_header(); ?>
    
    	<!-- section -->
    	<section role="main">
    	 <?php query_posts( 'post_type=articles'); ?>
    	<?php if (have_posts()): while (have_posts()) : the_post(); ?>
    
    		<!-- article -->
    		<article id="post-<?php the_ID(); ?>" <?php post_class("journalPost"); ?>>
    
    			<!-- post thumbnail -->
    			<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    					<?php the_post_thumbnail(); // Fullsize image for the single post ?>
    				</a>
    			<?php endif; ?>
    			<!-- /post thumbnail -->
    
    			<!-- post title -->
    			<h1>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    			</h1>
    			<!-- /post title -->
    
    			<!-- post details -->
    			<span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
    			<span class="author"><?php _e( 'Published by', 'articles' ); ?> <?php the_author_posts_link(); ?></span>
    			<span class="comments"><?php comments_popup_link( __( 'Leave your thoughts', 'articles' ), __( '1 Comment', 'articles' ), __( '% Comments', 'articles' )); ?></span>
    			<!-- /post details -->
    
    			<?php the_content(); // Dynamic Content ?>
    
    			<?php the_tags( __( 'Tags: ', 'articles' ), ', ', '<br>'); // Separated by commas with a line break at the end ?>
    
    		    <!-- <p><?php _e( 'Categorised in: ', 'articles' ); the_category(', '); // Separated by commas ?></p>
    
    		   		    <p><?php _e( 'This post was written by ', 'articles' ); the_author(); ?></p>   --> 
    
    			<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
    
    			<?php comments_template(); ?>
    
    		</article>
    		<!-- /article -->
    
    	<?php endwhile; ?>
    
    	<?php else: ?>
    
    		<!-- article -->
    		<article>
    
    			<h1><?php _e( 'Sorry, nothing to display.', 'articles' ); ?></h1>
    
    		</article>
    		<!-- /article -->
    
    	<?php endif; ?>
    
    	</section>
    	<!-- /section -->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    thanks again

  6. EveVaterlaus
    Member
    Posted 1 year ago #

    I added another long post so you can see what happens, the "more" on either one opens both in the same page.

    http://mindfulbirthny.com/wp/articles-by-mary-esther/

  7. alchymyth
    Forum Moderator
    Posted 1 year ago #

    this line <?php query_posts( 'post_type=articles'); ?> forces all posts to be shown on that template.

    as single-acticles.php is a post-type specific single template, this line should not be necessary.

  8. EveVaterlaus
    Member
    Posted 1 year ago #

    I have taken out that line but the behavior remains the same, should I re-make the posts to see it work?

  9. EveVaterlaus
    Member
    Posted 1 year ago #

    THANKS- that worked-
    at first I had just commented it out, but when I deleted the line it made it all work beautifully,
    Thanks so much for the help, always more to learn!

    Eve
    I will mark this resolved-

  10. EveVaterlaus
    Member
    Posted 1 year ago #

    one more question- why will the custom posts page nav li a in theh menu not show the .current-menu-item class?

    It would be nice to have that-

    http://mindfulbirthny.com/wp/articles-by-mary-esther/

    Eve

    more thanks again

  11. alchymyth
    Forum Moderator
    Posted 1 year ago #

    why will the custom posts page nav li a in theh menu not show the .current-menu-item class?

    your custom query in the page template ( ARTICLES-2-PAGE ) is disturbing the original query information;

    try to add:

    <?php wp_reset_query(); ?>

    after this line:

    <?php endif; ?>

  12. EveVaterlaus
    Member
    Posted 1 year ago #

    Voila!
    you are a genius!
    manymanythanks.

Topic Closed

This topic has been closed to new replies.

About this Topic