• Resolved saberj

    (@saberj)


    Ok, so I’ve been running my podcast website on WordPress for about 3 years now. It’s a pretty large website. I’ve been using Podpress for that entire time. However, there is VERY LITTLE support for it these days. I can’t just switch at this point, as I have hundreds of episodes currently.

    With that said, I’m having a problem with Podpress interacting with the_content()

    Here is what I’m trying to do. I want to make my category listings display a static page before it displays the posts in the category. Easy enough. There is a Category Page plugin. I used it, but what was happening is that after it displayed the Page Content, It would take the Podpress insert for the first post in that category, and attach it to the page, instead of the post.

    So, I thought it was probably a bad interaction between the two plugins. So I pieced together a home-brew version. It looks for a page of a certain name, and if it exists, it pulls it’s post_content. That works fine. Except, post_content strips HTML from the content when it displays it. So I have no line breaks in that form.

    The answer is to display the_content, or to apply_filters(‘the_content’, $page->post_content). However, as soon as I do either one of those, boom, the podpress content is right back into my page, and out of my first post.

    So, my question is this: Is there anyway to display a formatted version of a post/page’s content, without using the_content either as a call, or a filter?

    If the answer to that is no, then is there any chance someone could explain to me why the podpress content is being pulled when I am calling the page’s the_content, rather than staying with the first post like it should?

    At this point, I’m literally running out of options. I’ve tried to get help from the plugins forum, but nobody will answer at all. I can’t give up on podpress, as it is the backbone of my website. But I can’t come up with any other solution that doesn’t use the un-formatted text.

    Please, any help that can be given would be REALLY appreciated. I’ve been fighting this off and on for months now. I just can’t find an answer. For an example of what I am talking about, please see:

    https://www.geekshow.us/newdev/category/content/podcasts/buffcast/

    Notice the Audio players. Every one of them is right, except the first one gets moved up to the page content, rather than the post it comes from.

Viewing 15 replies - 1 through 15 (of 23 total)
  • I don’t understand. it looks okay to me. that being the case, I’ll bet it looks okay to your audience too.

    Oh, I see. You’ve got that stickied post or whatever at the top, and the podcast for it is below the one that it’s in.

    Okay, here’s my thoughts. Do you have a “home.php”? If no make one by coping your index.php. Take the contents of that stickly post and put it directly into your home.php making sure to enclose it in a <div></div> with a unique id and delete that sticky post.

    Thread Starter saberj

    (@saberj)

    That’s not a stickied post. That’s the contents of a page. The problem is that the audio player (See the Play button, download links, etc) are all at the bottom of the “page”, rather than being in the first actual post, like it should be.

    Now, I can’t go the route of the home.php, because I have no less than 11 different categories that will need a different setup that is still similar to what is on that page. Not just the one category, but 10 more as well.

    Are you using a query to pull in that first static content section? My guess would be that you’re not a) making a new query or b) resetting the old one.

    Probably the easiest thing to do would be to just put in a category description for that category, and then pull in the description to be displayed. Just go to your “Categories” area, edit our category, and put in a description. Then in your category.php file, where you want the “Static text” to show, just add:

    <?php echo category_description(); ?>

    That should pretty much do it.

    Thread Starter saberj

    (@saberj)

    It’s not a database query, if that’s what you are asking. It looks like this currently:

    if (get_page_by_title($categoryname . " Category")) {
    ?>
    <div class="archives box">
    <?php
    $page = get_page_by_title($categoryname . " Category");
    echo apply_filters('the_content', $page->post_content);
    ?>
    </div>
    <?php } else { ?>

    The same thing pretty much happens if I change it from the echo apply filters to echo the_content(), best I remember.

    The problem with just pulling the description, is that I’m not sure that solves the problem of accepting HTML, accepting pictures, etc. I’m willing to bet that the description also either strips the HTML, or doesn’t process it, one or the other.

    So that’s definitely thinking on the right track, but I’m not sure that it would be any better for my purposes than a straight up “echo $page->post_content;”

    Yes, the description takes links, but it won’t take much other HTML.

    And no, I don’t mean a database query. I mean a query (which I suppose is, but in a roundabout way.) I mean like using query_posts();

    However, you *can* pull in the description as a variable, and then write a function to arrange it’s output properly.

    So, for example, you want to have particular image to go with your category. You could name your image the same name as your category slug, and upload said image to your theme folder (just as an example). We’ll go with that – and say it’s a category called “Fish.” So your category image would be “fish_cat.jpg” (heh.)

    So you write your category description in your admin area. I’m assuming you just want a paragraph. (if not, you could probably make up your own filter and just use the function to replace that with line breaks. Like, say you use \\\ for the paragraph break…just use a preg_replace or something to replace the “\\\” with “</p>”, KWIM?) but we’re going with a single paragraph here for the example.

    So the function would then be something like (this is just off the top of my head, and I’m sure it could be done better!):

    <?php
    function my_cat_description() {
    $imgdir = get_bloginfo(template_directory') . '/images/';
    $getcat = get_the_category();
    foreach($getcat as $cat) {
    $catID = $cat->ID;
    $catslug = $cat->category_nicename;
    $catdesc = $cat->category_description;
    
    if (in_category($catID)) { ?>
    <div id="category">
    <img src="<?php echo $imgdir . $catslug; ?>_cat.jpg" alt="" />
    <p><?php echo $catdesc; ?></p>
    </div>
    <?php }
    }
    ?>

    I would think that *would* work – but I’m not positive. like I said, you might need to mess with it a bit.

    Then you just call in your funtion into the category.php file where you want it to appear:

    <?php my_cat_description(); ?>

    Thread Starter saberj

    (@saberj)

    If I used a preg_replace, then my descriptions would suddenly have (For example) “\\\” randomly placed in it, correct? My theme already displays the Description in other places, so I think that it’d be quite a bit of work to remove the descriptions elsewhere. Could it be done in a similar way that doesn’t involve ruining the description for use elsewhere? Perhaps still using a page, rather than the description? Then just still using the preg_replace instead of formatting the HTML?

    Thread Starter saberj

    (@saberj)

    One last request, since I suck at regex. Can someone post an example preg_replace that takes “\\\” and replaces it with “
    “?

    Everything is very appreciated. It’s nice to actually get pointed in the right direction. I still wonder why the_content() is pulling content from another section when I am working with pages. That would be the preferred and “pretty” fix. But this should work almost as well, if I can get it right.

    Well as to why it’s pulling in the wrong content, I can’t tell you without seeing *all* of the code for your file. however, I can venture a guess.

    if (get_page_by_title($categoryname . " Category")) {
    ?>

    I’m guessing $categoryname is the name of the page you’re wanting. You have your pages set up to reflect those categories. So bsaiclly, if you have a category called “Fish Food” then you also have a page called “Fish Food Category”.

    I don’t know whether this code appears on the page.php template, or the category.php template (or the archive.php template). I would think that what you’re trying to do is pull in a particular category to list on a Page. So if you’ve got this code on the wrong template file, that would be one reason it’s pulling in the wrong content.

    If you’re trying to pull in a listing of posts in a category to a particular Page, then it would be easier to just use the category description and bypass the query-by-page altogether, You’re just making more work for yourself than is necessary.

    >>If I used a preg_replace, then my descriptions would suddenly have (For example) “\\\” randomly placed in it, correct? <<

    Only if you did that in your descriptions – but where else are you planning to pull these into? And if you are, and you’re using the preg_replace, then no, it won’t show up anywhere else. I’d say the_content is pulling in exactly what it’s being told to pull in – so there’s an error in your coding somewhere. But with what you’re trying to do, just use the description. I’m not quite sure what the big deal is about doing that.

    For the record, I just went in myself and tested whether or not <p> tags would be put in if you used a category description, and they will. So no need for a preg_replace. (For the record, maybe you could have tried that yourself to see what tags would be retained? Just an example of maybe making things too hard on yourself – if you’re not sure, give it a shot and see what happens. The world won’t end, you know ;))

    Thread Starter saberj

    (@saberj)

    https://www.geekshow.us/newdev is the development version of the website I am working with this problem on.

    The reason I’m not jumping in on the idea of using the Category Description, is because it’s already being used. Currently, for the navigation bar, when you hover over an item, it will pop up the description and tell you what the category is about. If I start using the description area to store page content, then I either have to remove that, or deal with it listing a lot of content I don’t necessarily want to be displayed.

    For the record, the the_content() is being called for in archive.php, which is the file that determines if it’s a category archive, tag archive, search, etc. Then it displays the information accordingly. In this case, I have it setup to display the page as with the the_content filters applied, and that’s what calls in the wrong content.

    This is almost certainly a case of Podpress being out of date and not playing nice with the newer versions of WordPress. I say this not because I’m confident in my coding abilities (Because I’m not, at all). But because the plugin that does exactly what I need it to do (Page2Cat) has the same exact problem. So either we are making the same exact problem (Which is possible, since I know nothing about “Resetting a query”, and the plugin author may be making the same mistake), or the way the podpress player is placed in the post is causing issues.

    Still, at least now I have a direction to go in to try and find a solution. I’m just not sure the description is the best way to go about it.

    I’m also going to look into some of the themes out there that make WordPress into a CMS. I’ve always heard about how it could easily be themed that way, but it seems to be a whole lot of hoops to jump through if you don’t know what you are doing.

    Thanks, doodlebee

    >>. Currently, for the navigation bar, when you hover over an item, it will pop up the description and tell you what the category is about.<<

    Hm… I don’t see this. It just does your standard “View all posts under..” but no description. (I’m on FF3)

    >>I have it setup to display the page as with the the_content filters applied, <<

    But what content filters are you using? That’s the question. Did you write your own?

    >>since I know nothing about “Resetting a query”<<

    Well, what I mean about “resetting the query” is, you canpull custom posts in from the database using a query. the most common issue is when people use multiple Loops within a template file, but they don’t “reset” the first Loop back to it’s original state – therefore the Second Loop will screw up. Or sometimes the Second Loop will override the first. So if you have multiple Loops set up, and they’re done incorrectly, then it would make sense that the wrong content is being pulled in. You can tell – a new query says just that “query_posts”.

    >>I’m also going to look into some of the themes out there that make WordPress into a CMS. I’ve always heard about how it could easily be themed that way, but it seems to be a whole lot of hoops to jump through if you don’t know what you are doing.<<

    I agree. Although I make CMS’s all the time with WordPress, so it’s not an issue – but if you don’t know PHP then yeah, it can be challenging. However, I do know one of the most popular themes out there right now (that’s highly configurable) is Thesis. It’s a “premium” theme though – you have to pay for it. but I’ve heard nothing but great things about it.

    If you want to pass me your current theme files, feel free and I’ll take a look – might be faster to do that than try to guess what’s going on ?? My email is shelly AT foolishvisions DOT com ?? And what version of PodPress and WordPress are you using – as well as any other plugins you might be using? That’ll help to know too (just send it in the email with your theme files.)

    Thread Starter saberj

    (@saberj)

    Sorry, I should have pointed out that not all of the categories HAVE descriptions up. It’s on the to-do list, but I just haven’t gotten to it yet. Most of the entries in the Podcast list have descriptions, though.

    The problem is that I’m working with a lot of stuff I can’t necessarily rely on. My coding is primitive at best. I learn by dissecting other bits of code from other places, and trying to recreate it. Or when the Codex/Reference list is helpful, I will learn from that.

    However, I’m also using a premium theme called “Our Community”. It looks pretty well designed overall. But I have found an occasional mistake here or there. So I can’t rely on it being flawless.

    Add in the fact that WordPress is no longer supported, and we never got a 2.6 patch, much less a 2.7 patch, and the situation becomes even more unreliable.

    I can tell you this, as it may be more helpful. I’ve disabled EVERY plugin I have except for Podpress (since that’s obviously where the issue is rearing it’s ugly head), and it still happens. So at least we don’t necessarily have to worry about something else being the cause of the problem. It’s almost entirely isolated between the theme, my code alterations to the theme, and Podpress or it’s interactions with the_content.

    So yeah, let me go ahead and pack up my theme files, and I’ll toss them your way.

    I’m using WordPress 2.7 with Podpress 8.8 installed. I really appreciate the help, it’s a hard task self-teaching yourself to troubleshoot these sorts of problems.

    Edit: Forgot a question you asked that may be important. No, I did not write my own filter. I was under the impression that if you applied the “the_content” filter, that it would apply all the formatting without needing to write your own.

    ‘Kay – sorry it’s taken me so long – kiddies have been sick for the past week, so I’ve been playing catch-up with clients since yesterday.

    Okay, I’m going through this, and so far, it seems fine to me the way it is. You’ve got a TON of includes though – files leading to other files, so it’s kind of confusing to navigate through this. But I’ve found it – it’s in the category.php file. This is your problem:

    <div class="archives box">
    <?php
    $page = get_page_by_title($categoryname . " Category"); // this line grabs the name of the category archive page you're on, correct?
    echo apply_filters('the_content', $page->post_content); 
    
     ?>
    </div>

    What that’s doing – form what i can tell – is looking for a category, but pulling in the Page content that matches it. Typing that sounds confusing. LOL I can imagine what it’s doing to the server!

    So what you’re trying to do it pull in page content to your category page. I dont’ know where you got the abpve, but what you need is a query to pull in that page’s content into the section you want. I wish I could see *just* the page that you’re pulling in, but I can’t, so I’m going to have to do some guesswork here. But from what I can gather, you’re wanting to name a page “Cats”, and then you want a “Cats Category” that lists the archives. SO I think the code you’re using is just a little too simple. You’re trying to match up the name of the Page with the Category (from what I can tell). but what I *can’t* tell at the moment is if your page is displaying a category archive with the page contentpulled in before the archive listing, or if you’re using a Page and pulling in the categories below the Page content. I’m assuming it’s the first situation.

    So you want to first grab the page and category names for comparison, so you can match the Page to the Category, and since we’re going with scenario #1, you’ll want to do this in the category.php file. (You *may* want to follow up in the archive.php as well – but I leave that up to you.)

    Honestly, this would be TONS easier if you just named the Page the same thing as the Category, rather than appending “Category” to the category name. SO I’d recommend changing your category names to match the Page names, and then to the following:

    <?php
    //categories
    $catid = get_query_var('cat'); // get the current category ID
    $cat = &get_category($catid); // pull the current category info
    $catname = $cat->slug; // current category slug
    
    $pagematch = new WP_Query("pagename=$catname"); // if the Page name is the same as the category name..
    
    if($pagematch->have_posts()) : while($pagematch->have_posts()) : $pagematch->the_post(); ?>
    
    //do your page content display stuff here
    
    <?php endwhile; endif; ?>
    
    // now do the secondary loop that has the category listings as usual.

    That’s pretty much it.

    Thread Starter saberj

    (@saberj)

    Aha, a response! Thanks very much for taking the time to do this. Let me answer some questions first….

    The first code you included was basically grabbing the name of the category, appending the word “Category”, and then looking for a page with that name. So basically, if you were looking at a Category named “Foo”, it would then look for a page titled “Foo Category”. If that page exists, it was supposed to dump it’s contents onto the screen, then continue listing the contents of the category.

    You are correct in assuming I am using a category listing, and pulling the page content into that, not vice versa.

    Now, the thing is, the code that you pasted from my current code isn’t in a category.php file. In fact, I don’t even have a category.php file. That all comes from archive.php, where is does all the work for Categories, tags, daily archives, monthly archives, etc.

    SO…I used the code you gave me, and the problem I am having is this. It is always doing the stuff after the endwhile endif. Meaning, it’s never finding a match. I echo’ed the $catname, which gave me the category slug name as I assumed it would. However, I could never get it to match a page name of the same.

    $pagematch = new WP_Query("pagename=$catname"); // if the Page name is the same as the category name..

    Is there any chance that the above code is wrong in some way? It’s never making the match. I have a category with a slug “test”, and it’s not matching the page named “test”. But when I echo the $catname, it is in fact returning “test” as the slug.

    I don’t know anything about WP_Query, so I can’t make any suggestions as to what may be wrong. But obviously $catname is working as expected. The “pagename” part isn’t, though. Is that something that is a part of WP_Query? Or the DB? Or was that another parameter that was supposed to be set? Because I see nothing about it in the code you gave me.

    I apologize for the includes and such. That’s the way the theme came when I got it. When I was shopping for theme designers, it looked like it would cost in the thousands rather than the area around $100 to a max of $200 I was looking for. So I had to go with what I could get. I like the theme, but I can’t speak for how well it is designed, since I know nothing beyond the little bits of code I can patch together. ??

    Thanks again for your time and effort.

    >>However, I could never get it to match a page name of the same. <<

    When you changed your category names to match your Page names, did you change the *slug* of your category names as well? For example, a previous Page would have been named “Fish”, and originally, it would have been “fish-category”. but when you changed the name, you should have also changed he slug to “fish”. (or if the category slug is correct, do your Page slugs match them?)

    Sorry if I wasn’t clear on that.

    WP_Query is the same thing as “query_posts” except you’re creating a *new* Loop. When you’re using multiple Loops in the same template file, then you want to create new queries – much easier than making multiple query_posts calls and trying to reset them.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Pulling My Hair Out with the_content – Please Help’ is closed to new replies.