Solved

post content not showing in Wordpress.

Posted on 2010-11-15
13
407 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:jonathan1978
  • 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:jonathan1978
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:jonathan1978
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:jonathan1978
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:jonathan1978
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:jonathan1978
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:jonathan1978
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 500 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

778 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