php link to another page - php

im editing a wordpress theme for my own personal website. The page is for a blog, and what is meant to happen is that when you click on the 'read more' or blog title then it will open that blog in the seperate page to read. however when i click these 2 things i get the following message:
Server error The website encountered an error while retrieving
mywebsite/wordpress/?p=20. It may be down for maintenance or
configured incorrectly. Here are some suggestions: Reload this web
page later. HTTP Error 500 (Internal Server Error): An unexpected
condition was encountered while the server was attempting to fulfil
the request.
it was previously working before so i know the code that came with the theme worked. heres the code:
<div class="box">
<?php while ( have_posts() ) : the_post(); ?>
<article>
<h2><?php the_title(); ?></h2>
<h7>BY LOUIS MOORE ON</h7> <time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?> <?php the_time(); ?></time><?php the_content(); ?>
<a href="<?php esc_url( the_permalink() ); ?>"/><h8>READ MORE</a></h8> </br>
</br><div class="h9"></div>
</article></br></br></br>
<?php endwhile; ?>
</div>
im not the gretest at php and i havent really changed it from its original form other than the things such as 'read more' 'by louis moore' the second div and the </br>

There are several errors in the HTML code. Maybe that's the problem.
You may try this:
<div class="box">
<?php while ( have_posts() ) : the_post(); ?>
<article>
<h2> <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?> </h2>
<h7>BY LOUIS MOORE ON</h7>
<time datetime="<?php the_time( 'Y-m-d' ); ?>"> pubdate><?php the_date(); ?> <?php the_time(); ?></time><?php the_content(); ?>
<h8>READ MORE</a></h8>
<br /><br />
<div class="h9"></div>
</article><br /><br /><br />
<?php endwhile; ?>
</div>

Related

Wordpress post page loop acting strange

I am having an issue with my Wordpress post loop where if I add or update a post it decides to kill one odd and it disappears? Has any had this issue before?
<?php query_posts('posts_per_page=4&cat=3'); while(have_posts()) : the_post(); ?>
<div class="eventPostOuter">
<div class="eventPost">
<span class="eventsImage">
<?php the_post_thumbnail( array(200,200) ); ?></span>
<h3><?php the_title(); ?></h3>
<span style="padding-bottom: 40px;" class="exerpt"><p><?php echo substr(get_the_excerpt(), 0,200); ?> [...]</p></span>
<!--<span class="excerpt" style="padding-top: 20px;"><p><a class="excerptLink" href="<?php the_permalink(); ?>">Read full article</a></p></span>-->
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
That is my code, perhaps I have made an error in there somewhere? I am unable to see what the issue is and it has only just begun doing it...
Ok, I fixed the issue which is so strange, I changed the character limit from 200 to 180 and all of the posts show perfectly. :S

Wordpress post loop

So im trying to add a function called "latest posts" in a sidebar section.
This is how my code looks like in sidebar.php-file.
<?php
query_posts('category = all');
if (have_posts()) :
while (have_posts()) : ?>
<?php the_post();
the_excerpt(); ?>
<p class="datum2"><?php the_time('Y-m-d'); ?></p>
<p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
<p class="textnyhet2">
</p>
<?php endwhile;
endif;
?>
My problem is, no matter how much I move around in the code I just cant seems to get the correct title/date to appear above the correct post.
Now it's like the post comes first, then right under the post the date and title appears above another incorrect post etc.
Example:
Latest post text
space---->
title/date, (though to the post above)
latest post text
space----->
and continue like that.
Would be grateful if anyone could help me out.
Thanks!
The reason the title/date appears below the post is because that's the way you have specified it to appear. Change
<?php the_post();
the_excerpt(); ?>
<p class="datum2"><?php the_time('Y-m-d'); ?></p>
<p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
<p class="textnyhet2">
</p>
to
<?php the_post(); ?>
<p class="datum2"><?php the_time('Y-m-d'); ?></p>
<p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
<?php the_excerpt(); ?>
<p class="textnyhet2">
</p>
It should display the way you want it.
the_excerpt(); is printing out an excerpt of the post, then the time/title displays. Now it should display the time and title first, then display the excerpt of the post.

PHP codes for wordpress

Hello guys so I am making a car review wordpress magazine and I am having issues with php codes as I am not a great programmer. Actually on this page Memes I would like the social plugins to be below each picture and not on the top furthermore I would like it to display the post date and the author of the post. Some formatting for the pictures size etc would be great too. Below is the code I am using
<?php /*
Template Name: ListPostsInCategoryThatHasSameNameAsPage
*/ ?>
<?php get_header(); ?>
<div id="content" class="archive <?php if(get_option('colabs_layout_settings')=='two-col-right'){echo 'right';}else{?>left<?php }?>">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?> id="post_<?php the_ID(); ?>">
<span id="map"><?php _e('Home','colabsthemes');?> » <?php the_title(); ?></span>
<h2 class="title"><?php the_title(); ?></h2>
<div class="entry" style="padding-top:15px;">
<?php the_content(__('<p>Read the rest of this page »</p>','colabsthemes')); ?>
<?php echo colabs_share();?>
<?php wp_link_pages(array('before' => __('<p><strong>Pages:</strong>','colabsthemes'), 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
</div>
<?php endwhile; else: endif; ?>
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?>
<?php endwhile; else: endif; ?>
</div>
</div>
<div id="sidebar" class="<?php if(get_option('colabs_layout_settings')=='two-col-right'){echo 'left';}else{?>right<?php }?>">
<?php get_sidebar(); ?>
</div>
<div> <?php get_footer(); ?> </div>
Finally for the review part I would like to do something like Autotest/review but I don't know which code to use to show these kind of square articles. Please help me out.
For adding the author and date of the post, you can add:
<p>Written by:
<?php get_the_author(); ?></p>
get_the_author() will display the author's name as is set in their "Display name publicly as" field in their user profile (Administration > Users > Your Profile).
To also display the date:
<p>Written by:
<?php get_the_author(); ?> on
<?php get_the_date(); ?></p>
I don't see where you're using the social sharing links on the page you linked to - did you remove them?
For more information:
http://codex.wordpress.org/Function_Reference/get_the_author
http://codex.wordpress.org/Function_Reference/get_the_date

Getting the post title in index php in a while loop

I have
<?php while ( have_posts() ) : the_post(); ?>
<div class="boxes-third boxes-first">
<div class="latestthree">
<div class="title">
<?php get_the_title($id); ?> // I am trying to get the post title here but doesn't work
<span class="titlearrow"></span>
</div>
<div class="latestthreeimage">
<a rel="prettyPhoto" title="<?php get_the_title($id); ?>"> /same here
<?php the_post_thumbnail(array(300,133)); ?>
</a></div>
<div class="text">
Here i would like to get the excerpt of the post that is no longer than 25 words
<span class="textarrow"></span>
</div>
</div>
</div>
<?php endwhile; ?>
I am trying to do the above mentioned, but did not worked and on the last one did not find related info. I am using wp 3.7.1. Please help me.
You have used get_the_title() which does not print. To print out the title, add an extra echo:
<?php echo get_the_title(); ?>
Or you can use the_title(), which also prints:
<?php the_title();?>
Try just using,
the_title();
Reference.

Is this an acceptable wordpress loop?

New to php and the loop process. Is it okay to have html markups inside the loop? Also I often see something like <?php get_template_part( 'content', get_post_format() ); ?> or a more complicated version in other themes. Should I house the loop in a separate php file and call it in my posts page?
I just want to make sure that my loop follows the "wordpress rules" and does not look out of the norm. Here is my current loop code that does function properly:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<p>
Published on <?php the_time('M j, Y'); ?> <br>
</p>
<p><em>
by <?php the_author(', '); ?> in <?php the_category(', '); ?> | <?php comments_number(); ?><br>
</em></p>
<?php echo get_the_post_thumbnail($page->ID, 'home-thumb'); ?>
<br>
<p><?php the_content(); ?></p>
<hr>
<?php endwhile; ?>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
<?php else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
It is ok to use markups in the loop, in fact most themes are done that way.
Functions like are just used for reusable code.
get_template_part( 'content', get_post_format() );
If you are going to use that loop elsewhere, separate it into another file. If not, keep it in the same file.

Categories