[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

post content not showing in Wordpress.

Posted on 2010-11-15
13
Medium Priority
?
437 Views
Last Modified: 2012-05-10
My page content is not showing on my page as it is clashing with a plugin i have installed.

I have a upcoming events widget that i want to display on my sidebar, and it works fine, but then my page post does not show. I have registered the plugin, and have it as sidebar_Events.php included in my sidebar. If i take it out the page content displays correctly, but if it leave it in, then no page content.  How can i work round this? as i definitely need the upcoming events to be displayed aswell.

Here is the code that displays my content, and i have attached the upcoming_events.php plugin. No links as i am developing this site on wamp locally.

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <?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')); ?>
            <?php endwhile; endif; ?>

Open in new window

upcoming-events.php
0
Comment
Question by:Jon Imms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
13 Comments
 
LVL 2

Expert Comment

by:gtagliani
ID: 34140410
I have tested the plugin u uploaded on a wp 2.8 and its working fine. what version of wp are u using?
0
 

Author Comment

by:Jon Imms
ID: 34140498
I am using 3.0.

The Plugin works fine,  shows up in my sidebar, but then my page content is blank.  If i remove the included plugin, the content appears again.
0
 
LVL 2

Expert Comment

by:gtagliani
ID: 34140667
you have to activate the plugin(in the admin panel) and after that put this code:
 upcoming_widget(); 

Open in new window

in your sidebar.php

i have tested this in a wp 3.0.1 and its working
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jon Imms
ID: 34140795
still not working ?

I had already activated the plugin.  can you see what i am doing wrong here ?

 
functions.php
sidebar-Events.php
Arts-For-Life-sidebar1.php
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34167695
Is the post content there if  you view the page source?
0
 

Author Comment

by:Jon Imms
ID: 34168699
no, I have viewed the source code, and it does not appear.
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34173237
hi,

that plugin uses query_posts, which sets what content is in the_loop... so if you call it before displaying your page, it is replacing the posts that should be used for the page with the posts of the upcoming events, meaning you would need to place the code that displays your sidebar after your code that displays your post, or grab your post id first and then do query_posts again with that saved ID to get your original post back in the_loop after displaying the sidebar.

I am guessing this is the case, as you didn't supply your entire single.php I can't be sure, but based on what you are saying and how it seems that plugin functions it makes sense to me. I have included what I think should work for you in the code below, but I am unfortunately unable to test it right now. So top part of the following code goes directly above wherever you call your sidebar, and then right after your call to sidebar call queryposts again
<?php 
if (have_posts()) : while (have_posts()) : the_post();
$posttodisplay = get_the_ID();
endwhile;endif;

get_sidebar();

query_posts("p=$posttodisplay");
?>o 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <?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')); ?>
            <?php endwhile; endif; ?>

Open in new window

0
 

Author Comment

by:Jon Imms
ID: 34185160
Sorry, Not working.  I forgot to post my pages before, so here are  the pages in question.  If i leave out
<?php include 'sidebar_Events.php' ; ?>

Open in new window

from my sidebar, then the main content on my page is displayed. If i Leave it in, then the post disapears, but the Events appears.

Arts-For-Life-sidebar1.php  partnersPage.php sidebar-Events.php functions.php Arts-For-Life-Header.php
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34188681
Hi,

in partnersPage.php

change

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

to

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

and see if it outputs the id of the post(s) it has
0
 

Author Comment

by:Jon Imms
ID: 34189282
Hi Jrm213jrm213,

I tried your suggestion, but still no output of the post.
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34189419
is there absolutely nothing output? If nothing is being output then as I mentioned before it seems like the plugin is causing the the_loop to get messed up.

try putting
include 'Arts_For_Life_sidebar1.php';

right before:
include 'Arts_For_Life_footer.php';

I realize it will mess up the display of the page, but I am thinking it should display the post and the sidebar info, if it is the sidebar code messing up the loop.
0
 

Author Comment

by:Jon Imms
ID: 34189574
I included the sidebar just before the footer.

I used your code above, and it displays the page ID, and then Post content.  The sidebar moves down the screen.

I used my code, with the sidebar just before the footer, and that displays the post content with the sidebar moving down the screen.    So now we know that is the problem, how can i get my sidebar back up the page.

Here are 2 screen shots showing the output.  Needed to zoom out to get most of screen captured. Top one is with your code, showing the outputted page ID, and Post Content.  

 ScreenDump Original Screen
0
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 2000 total points
ID: 34190268
in partnersPage.php I would replace

<?php
include 'Arts_For_Life_Header.php';
include 'Arts_For_Life_sidebar1.php';
?>

with the snippet below. Now Is the page you have screenshots of above considered a "page" or a "post" in wordpress?

You use query_posts differently depending so it would either be

//POST
query_posts("p=" . $posttodisplay);
or
//PAGE
query_posts("page_id=" . $posttodisplay);


I know I mentioned doing this before, but I feel like it has to work...

<?php
if (have_posts()) : while (have_posts()) : the_post();
$posttodisplay = get_the_ID();
endwhile;endif;

include 'Arts_For_Life_Header.php';
include 'Arts_For_Life_sidebar1.php';

query_posts("p=" . $posttodisplay);
?>

Open in new window

0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question