• 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 8 replies - 16 through 23 (of 23 total)
  • Thread Starter saberj

    (@saberj)

    Yeah, the page is named after the Slug, not the category itself. I echo’ed the $catname variable just to verify that it was checking for what I assumed it was checking for. But it still won’t come up with a match. But as I said, I can’t figure out where “pagename” is coming from in that case. Is it a built in function for WP_Query?

    Doodlebee

    (@doodlebee)

    New Queries (i.e. WP_Query): here

    Post & Page Parameters (for queries)

    >>Yeah, the page is named after the Slug, not the category itself.<<

    I’m not sure what you mean here. The Page is named after what slug? And does the Page slug match the category slug? That’s what it’s looking for – whether the category slug and the Page slug are the same. If they aren’t, they won’t find a match.

    Thread Starter saberj

    (@saberj)

    Ok, that was the missing piece. I knew that the category was looking at the slug. But I had no idea that pages even had slugs, much less that it was looking for one. Sure enough, my screen options were hiding the page slugs. Once I gave that a change, it showed up.

    However, I was wondering what the best function would be to grab the page contents. Currently I’m using:

    $page = get_page_by_title($catname);
    echo apply_filters('the_content', $page->post_content);

    There are two problems with this function. First, it’s getting the page by the name, rather than by the slug. So I have to actually give the page name the same name as the slug in order for it to work.

    Secondly, applying the filters seems a little inconsistent. Sometimes the line breaks work, sometimes they don’t. What would you suggest to pull the page contents?

    Thanks again. It looks like I’m very close to getting it working as intended thanks to that help. It’s still a bit off due to the formatting. But at least it isn’t showing the episode player like it used to. See:

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

    That is an example of some of the line breaks working. However, there should also be one after the image, and that’s being stripped for some reason. Compare to the actual page’s formatting: https://www.geekshow.us/newdev/buffcast/

    Also:

    https://www.geekshow.us/newdev/category/content/podcasts/angel-investigations/

    That pretty much only has one line break working. The rest don’t work at all. Compare to the actual page’s formatting: https://www.geekshow.us/newdev/angel-investigations/

    Thanks again. I think that about wraps everything up. ??

    Thread Starter saberj

    (@saberj)

    I got the line breaks sorted out. But I still can’t find function that looks for a page by slug, rather than by name. Thanks again!

    Doodlebee

    (@doodlebee)

    >>However, I was wondering what the best function would be to grab the page contents. <<

    I supplied the code for this above. once you get the category slug and page slug to match, you just use a regular posting layout (with the_content()) to pull in the information, You don’t need special filters – you’re already using a special query to pull in the correct information. Lay it out the same way you would any other post. it’s already pulling in the content that you want without any extra work.

    >>But I still can’t find function that looks for a page by slug, rather than by name.<<

    That’s in the code above. let me show you again:

    $pagematch = new WP_Query("pagename=$catname");

    What this does is look for a page slug that matches the category name you are querying. If it finds one, it displays the page information. If you took that piece of code and put in “pagename=fish” it would pull in the contents of the Page with a slug of “fish”. You’re just replacing “fish” with a dynamic variable: the category name you want.

    Thread Starter saberj

    (@saberj)

    I’ve tried for the last two days to play with $pagematch, and can not get it to display anything. Not $pagematch->the_content(), not $pagematch->the_post(), not just $pagematch. I’ve been echoing all of those things, with or without applying filters, but nothing works. So I think you are going to havedumb it down a little more for me.

    //do your page content display stuff here

    I want to put the page display there, what goes there?

    echo $pagematch->the_content();

    OR

    echo the_content();

    OR

    echo $pagematch->the_post();

    OR

    the_post();

    I’m pretty sure I’ve tried all of those, without any success. Did I miss something and it is one of those? Or am I still missing something there?

    You said you supplied the code to do this above, and that’s probably true, but I still haven’t seen how it’s actually supposed to be used.

    Doodlebee

    (@doodlebee)

    the_content(). That’s it.

    >>I’ve tried for the last two days to play with $pagematch, and can not get it to display anything. <<

    $pagematch *doesn’t* display anything, it’s a *query*. It’s querying the database to look for what you tell it to look for. *if* it finds it, it will then display the code *after* it – which is the Loop.

    The standard Loop in WordPress is:

    <?php if(have_posts() : while(have_posts() : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; endif; ?>

    All I’m doing is telling you how to alter that Loop so it matches a certain set of parameters. the general Loop pulls everything if it exists, it displays. $pagematch is just a query to tell the Loop to look for a Page that has the *slug* that is the *same as the category you are on*. If it finds a page that has a slug of “fish” and the category has a slug of “fish” then it will display the Page content – which is the stuff *within* the Loop.

    <?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(); ?>
    
    <?php the_content(); ?>
    
    <?php endwhile; endif; ?>

    Thread Starter saberj

    (@saberj)

    Ok, for some reason I was thinking I needed to echo that. Thanks a lot.

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