• Situation:
    1. I’m using Exec-PHP plugin to allow using php in my Pages.
    2. I save my Pages codes in an external php file and in my ‘edit Page’, I link it like so:
    <? require_once(ABSPATH. '/wp-content/custom-php/my_custom_page.php'); ?>
    as suggested by someone online.
    3. I’m using custom fields to retrieve and display only some info from 3 specific posts (i.e thumbnail and a short description).

    Problem:
    I am able to display my custom fields. However, I also end up showing the 3 posts entirely at the end of my custom fields.
    How do I prevent wordpress from showing the entire post automatically. I am not very good with php, and work through trial and error, but got stuck at this for too long already.

    If anyone can give me some insight, it would be much appreciated.
    Thanks!

    Code:
    page.php

    <?php get_header(); ?>
    <?php include("menu.php"); ?>
    
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<h1><?php the_title(); ?></h1>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    
    	<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    my_custom_page.php

    <?php query_posts(array('post__in' => array(14,17,20))); ?>
    	<?php while (have_posts()) : the_post();
    		global $post;
    		$fdesc = get_post_meta($post->ID, "desc", TRUE); /* define the custom field with key = desc */
    	?>
    	<div class="" id="post-<?php the_ID(); ?>">
    		<p><?php echo $fdesc; ?>
    	</div>
    
    <?php endwhile; ?>

    One interesting thing is, I tried this code in page.php in one of my theme

    <?php if (have_posts()): ?>
    	<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    <?php endif; ?>

    and that seemed to solve the problem, but when i changed to my new theme, this code shows a blank page (i.e not able to direct to my custom page).

Viewing 1 replies (of 1 total)
  • Thread Starter noyu

    (@noyu)

    update:

    I have not found the solution but have an alternative.

    To create customised ‘Pages’ in wordpress, simply use put all your codes into a php file and make it a customised page template (just by adding template comment at the top. http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates)

    Then in WP control panel,
    Edit Page> Attribute > Template > choose your customised page template

    This way, you don’t even need to use Exec-php to execute php codes in posts. Just leave the content blank and put all your content in the customised page template.

    hope this helps someone out there. cheers.

    p.s, i am still curious how to solve my previous problem. if anyone knows, do leave a comment. thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘Not show entire posts in Customised Page’ is closed to new replies.