• I was wondering if someone could be so kind as to clean this up for me so that I don’t have to keep on defining the post, but instead define it once at the start and just use the normal title, content and featured image tags etc.

    Thanks heaps.

    <h2><?php $post_id = of_get_option('tabber_post1', 'no entry' ); $queried_post = get_post($post_id); echo $queried_post->post_title; ?></h2>
    
    <h1><a href="<?php echo get_permalink($post_id = of_get_option('tabber_post1', 'no entry' )); ?>" rel="bookmark"><?php $post_id = of_get_option('tabber_post1', 'no entry' ); $queried_post = get_post($post_id); echo $queried_post->post_title; ?></a></h1>		
    
    <?php $post_id = of_get_option('tabber_post1', 'no entry' ); $queried_post = get_post($post_id); $content = $queried_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Pete: You could try this

    <?php
    // only get post and option once:
    $post_id = of_get_option('tabber_post1', 'no entry' );
    $queried_post = get_post($post_id);
    ?>
    
    <h2>
    	<?php echo $queried_post->post_title; ?>
    </h2>
    
    <h1>
    	<a href="<?php echo get_permalink($post_id); ?>" rel="bookmark">
    		<?php echo $queried_post->post_title; ?>
    	</a>
    </h1>		
    
    <?php
    $content = $queried_post->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    ?>
    Thread Starter Pete

    (@perthmetro)

    Thanks, close but not quite there ??

    check out my home page (shockwave-electrical.com).

    I’m using your code for the first post in the tabber’ section, so the tab is gone and it’s post goes above the content of the other tabs… make sense?

    First, the line

    $content = str_replace(']]>', ']]>', $content);

    is not doing anything, you could get rid of it.

    Mabye you are missing some html-tags?

    For example:

    <div class="tabbertab  " title="">
    
    <?php
    // only get post and option once:
    $post_id = of_get_option('tabber_post1', 'no entry' );
    $queried_post = get_post($post_id);
    ?>
    
    <h2>
    	<?php echo $queried_post->post_title; ?>
    </h2>
    
    <h1>
    	<a href="<?php echo get_permalink($post_id); ?>" rel="bookmark">
    		<?php echo $queried_post->post_title; ?>
    	</a>
    </h1>		
    
    <p>
    <?php
    $content = $queried_post->post_content;
    $content = apply_filters('the_content', $content);
    echo $content;
    ?>
    </p>
    
    <div class="clear"></div>				
    
    </div>

    edit: sorry for the comment duplication

    (removed this duplicated comment)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘code clean-up: querying a specific post’ is closed to new replies.