I’m currently working on a photography website.
i’m trying to custom one of the plugins templates, which uses a custom post type.
I have managed to alter the template to display most of the information i want BUT.
I would like to load post content, but i only get shortcodes to display. I know i’m using the wrong piece of code <?php echo get_the_content() ?> but <?php the_content() ?> didn’t work, and i don’t know why.
HELP?
thank you in advance
]]>Im using a plugin to display post conte`nt in a lightbox whenever you click on a featured image. this all works fine if I just add normal text etc. But when I try to add a shortcode it just completly ignores it.
When I go to the plain page it just displays the plugin I added with shortcode. but when I open the page in the lightbox it doesnt display it.
I use the following code to load and display the content in the lightbox:
if($_REQUEST['popup']!=''){
$postObj = get_post( $_REQUEST['pid'] );
echo '<div class="ostContent">'.$postObj->post_content.'</div>';
Why does this code display the content I wrote but not the plugins I try to load using shortcode?
Greetings,
Merijn
]]>get_content()
since I have a custom script to apply ‘Read more’ links to individual posts.
Only when the function defaults to the_excerpt()
, do the buttons show up.
Is there a way to make it show the buttons in this case?
My function:
function show_content_before_more_tag($post){
global $more;
$more = 0;
// checks to see if the is a 'more' tag in post
// show if theres is
// truncate post if there is not
$ismore = @strpos($post -> post_content, '<!--more');
if($ismore){
$content_arr = get_extended( get_the_content() );
echo $content_arr['main'];
} else {
the_excerpt();
}
}
// Replaces the excerpt "more" text by a link
function new_excerpt_more($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read more.</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
]]>function getContentByID($id)
{
//https://wordpress.stackexchange.com/questions/9667/get-wordpress-post-content-by-post-id
$content_post = get_post($id);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
Can you tell me, why there isn’t any core function for this ? There are functions like get_the_title($id), get_the_category($id) …
]]>I am using the twentyeleven theme but have a problem with the category archive pages only showig the header and readmore elements of each post and not any of the content. I am using
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
to call the content but it is not working.
Any ideas why I may be struggling?
]]>Is this right? It works, I just want to make sure it is the correct way and most efficient.
<?php if($content = $post->post_content ) {
echo "<span class='titles'>Description:";
echo "</span>";
echo the_content();
} else {
echo "<span class='titles'>More Info Coming Soon</span>";
} ?>
thanks
]]><iframe name="home" src="https://www.YourHome123.com/forms/155_Search100sOfProperties.asp?userid=999300" id="myiframe" width="100%" scrolling="no" height=<?php echo $page_height; ?>>
<p>Your browser does not support iframes.</p>
</iframe>
<?php
$page_height = get_post_meta($post->ID, 'mask_page_height', true);
?>
In view source – value is not set just displays above code.
Any help would be greatly appreciated do to cross-domain and masking issues.
]]>Its quite simple really, I would like to display all posts on one page no matter when they were published (I will introduce pagination also). I don’t mean display just each posts title & publish date I would like the full post to be displayed. That includes the content (of the post) in full. Here is the code I have so far on PasteBin https://wordpress.pastebin.com/WMK0hNGv
This code currently pumps out just the title & the dates, missing out the code i’ve put in for displaying the actual posts content. The line that keeps being ignored is this:
<?php
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
?>
I got that code from the codex pages: under the Alternative Usage section.
Why won’t the full posts content get pumped out aswell? Can anyone help?
]]>Random title 1
Content from the latest post
Random title 2
Content from the latest post
Random title 3
Content from the latest post
…and so on. How should I code my homepage to show the content from the random posts instead? My current code is thus:
<?php get_header(); ?>
<div id="wrap">
<div id="content-container">
<div id="content">
<div class="post-container">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="posttop">
<!-- <div id="date">
<p class="day">
<?php the_time('j'); ?>
</p>
<p class="month">
<?php the_time('F'); ?>
</p>
</div>-->
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?>
</a></h2>
<div class="postinfo"><?php the_time('l, F j Y') ?></div>
<div class='postinfoauthor'>Written by
<?php the_author(); ?>
<?php edit_post_link('Edit', ' | ', ''); ?>
</div>
</div>
<div class="entry"><p> </p><p> </p><p> </p><p> </p><p> </p>
<?php the_content('<br />Continue reading: ' . the_title('', '', false)); ?>
</div>
<!--
<div class="postbottom">
<div class="metainf">Filed Under:
<?php the_category(', ') ?>
</div>
<div class="commentinf">
<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>
</div>
</div>
-->
</div>
<?php endwhile; ?>
<!-- <?php include (TEMPLATEPATH . '/navoptions.php'); ?>-->
<?php else : ?>
<h2>Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>
<div class="entry">
<h2>A random selection of my writing</h2>
<?php
$rand_posts = get_posts('numberposts=5&orderby=rand');
foreach( $rand_posts as $post ) :
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php the_content('Read more...'); ?></a>
<?php endforeach; ?>
</div>
</div>
<div style="float:left">
<?php get_sidebar(); ?>
</div>
</div>
<div class="bgbottom"></div>
</div>
</div>
<?php get_footer(); ?>
]]>