• Resolved ocpplus

    (@ocpplus)


    Hi All,

    Getting a headache on this one.

    This my site. I am trying to get the “more” section to display an excerpt, just like the “popular posts” section does. It is only showing blanks, but when looking at the page source code it shows the text is there. Theme is Technical Speech.

    The code for this area is:

    <div class=”contentbox”>
    <div class=”boxheading”><span>Most Popular</span><div class=”clear”></div><div class=”left”></div></div>
    <div class=”blockborder” id=”pop_border”>
    <?php popularPosts(); ?>
    <div class=”clear”></div>
    </div>
    </div>

    <div class=”contentbox”>
    <div class=”boxheading”><span>More</span><div class=”clear”></div><div class=”left”></div></div>
    <div class=”blockborder” id=”pop_border”>
    <?php
    $postslist = get_posts(‘numberposts=6&order=DSC&orderby=date’);
    foreach ($postslist as $post):
    setup_postdata($post);
    ?>

    <div class=”postblock”>
    <div class=”postblockwrap”>
    <h6>” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></h6>


    class=”readmorelink”>Read More

    </div>
    </div>

    <?php endforeach; ?>

    I have added Bold to the main part of the code for this, and Italic to the area which I believe could be the area that needs changing. I have tried get_posts etc.. but to no avail.

    Look forward to any input on this one. Thanks in advance.

Viewing 15 replies - 1 through 15 (of 21 total)
  • there is nothing in the html code in the browser, apart from the h title and the read-more.

    could you repost this area:

    <div class="postblock">
    <div class="postblockwrap">
    <h6>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></h6>
    
    "
    class="readmorelink">Read More
    
    </div>
    </div>

    this time using the code button (either paste your code, hightlight it, click the code button; or – click the code button once, paste the code, click the code button again) to prserve the actual code and keep it readable

    Thread Starter ocpplus

    (@ocpplus)

    <div class="boxheading"><span>More</span><div class="clear"></div><div class="left"></div></div>
    						<div class="blockborder" id="pop_border">
    							<?php
    	  							$postslist = get_posts('numberposts=6&order=DSC&orderby=date');
    	  							foreach ($postslist as $post):
    	  							setup_postdata($post);
    	 						?>
    
    							<div class="postblock">
    								<div class="postblockwrap">
    									<h6><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6>
    
    									<a href="<?php the_permalink() ?>"
    									class="readmorelink">Read More</a>
    
    								</div>
    							</div>
    Thread Starter ocpplus

    (@ocpplus)

    The above is the code that is for the section “more” on the website – thanks in advance.

    that is in your code

    <h6><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6>
    
    									<a href="<?php the_permalink() ?>"
    									class="readmorelink">Read More</a>

    and that is exactly what you get on your page in the browser.

    if you want to show the excerpt, you probably need to ‘borrow’ some code from the ‘popular post’ section; maybe something as simple as <?php the_excerpt(); ?>.

    try and change the lines above into:

    <h6><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6>
    
    <?php the_excerpt(); ?>
    									<a href="<?php the_permalink() ?>"
    									class="readmorelink">Read More</a>

    Thread Starter ocpplus

    (@ocpplus)

    Ok, added and saved but no joy on that front, code is correct, even when you check source code you can see the text in there. I honestly thought it had something to do with this section of code.

    <?php
    	  							$postslist = get_posts('numberposts=6&order=DSC&orderby=date');
    	  							foreach ($postslist as $post):
    	  							setup_postdata($post);
    	 						?>

    Which when I remove forces the thing to crash. This snippet is just above the obvious part.

    on a closer look, it seems that you are editing the wrong template file, as the html in the ‘more’ section shows this above each posts:

    <div style="height: 304px;" class="postblock">
    								<div class="postblockwrap">
    									<h6>....

    where this particular bit style="height: 304px;" is not in the code you posted.

    Thread Starter ocpplus

    (@ocpplus)

    In the wordpress code it is slightly different to that of the source code. When we php Get_post for example, that is not shown in the source code, only the post is.

    i am talking about the html part of the code – which shows different on your site than in your posted section of code; therefore the posted code does most likely not belong to the template that is responsible for showing the front page.

    question: is there possibly another template file to show the front page?

    http://codex.wordpress.org/Template_Hierarchy

    Thread Starter ocpplus

    (@ocpplus)

    I have index.php and home.php (Which is where the front page code is), the index.php has the following although I cannot see anything related to the section where I have the issue.

    <div class="contentbox">
    						<?php if (have_posts()) : ?>
    							<div class="boxheading"><span>Latest Posts</span><div class="clear"></div><div class="left"></div></div>
    							<?php while (have_posts()) : the_post(); ?>
    								<div class="posts">
    									<h6 class="postheading" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6>
    									<?php the_excerpt(); ?>
    									<a href="<?php the_permalink() ?>" class="readmorelink">Read More</a>
    									<div class="postsmetadata">
    										Category : <?php the_category(', ') ?>.<br />
    										<?php the_tags( 'Tags: ', ', ', '.<br />'); ?>
    										<?php edit_post_link('Edit Post', '', ''); ?>
    									</div>
    								</div>

    ok – i found out that this style="height: 304px is inserted by some javascript – you might be editing the right file after all.

    do you have any cache software activated that would stop your site showing latest changes?

    Thread Starter ocpplus

    (@ocpplus)

    No cache software, as a test I have put in a word that will show up. Tricky one this isn’t it.

    instead of
    <?php the_excerpt(); ?>

    (which obviously does no output anything, despite being in the original code of the theme)

    try:
    <?php echo apply_filters('get_the_excerpt', $post->post_content); ?>

    (which should, in theory, create an automatic excerpt; it will not use a manually entered one)

    or try to output the full content with:
    <?php the_content(); ?>

    ps:
    there is always the chance that a plugin is interfering:
    if anything alse fails, try and deactivste all plugins, and if the issue is then resolved, re-activate one plugin after the other to see which is causing it.

    Thread Starter ocpplus

    (@ocpplus)

    Getting there, I like the way the image is also involved, just need to cut the text or limit it somehow. Any ideas on that?

    I like the way the image is also involved, just need to cut the text or limit it somehow.

    is that done with ‘the_content()’ ?

    if so, instead of <?php the_content(); ?>

    you could try these lines of code:

    <?php $text = get_the_content();
    $words = explode(' ', $text, 80);
    array_pop($words);
    $text = implode(' ', $words);
    echo '<br/>' . apply_filters('the_content', $text);
    ?>

    adust the number 80 to fit the space.

    however, i would still rather like to find the real cause why ‘the_excerpt()’ is returning nothing …

    Thread Starter ocpplus

    (@ocpplus)

    At the moment it is with <?php echo apply_filters('get_the_excerpt', $post->post_content); ?>

    When I added the $text line it crashed. the_excerpt works fine on other pages so it is strange.

Viewing 15 replies - 1 through 15 (of 21 total)

The topic ‘Headache on this theme regarding some code.’ is closed to new replies.