Classifieds not displaying to front end

I am unable to the classifieds posts to display to the front end of the website.

http://5dds.fostermartin.net/cf-categories/classifieds/equipment-for-sale/

It declares "No posts found" even though the post exists.

Even an individual post doesn't display to the front end.
http://5dds.fostermartin.net/classified/new-equipment-for-sale/

I have deactivated/reactivated the plugin and the posts still do not display to the front end.

Any help pointing me in right direction would be great! Thank you for your help.

  • Patrick

    Hi there @fostermartin

    Welcome to the forums, glad to have you aboard!

    Activating a new post-type for the first time on a site can often result in "page-not-found" errors (it's a long-standing quirk in WordPress).

    That can most often be fixed by simply refreshing your permalinks. To do so, go to Settings > Permalinks in your wp-admin and set them to anything other than what they are now. Save. Then set them back to what you had before.

    Note that when using multiple custom post-types on a site, the %postname% option is usually the best choice.

  • fostermartin

    Hi Patrick,

    Thanks for your quick response!

    I resaved the permalinks, this unfortunately didn't resolve the issue.

    In an attempt to troubleshoot the classifieds display issue, I created a copy of page.php and renamed it page-classifieds.php.
    I would have expected this to override the page.php for the classifieds pages, but it did not.

    Additionally, I am unable to conditionally target the parent "classifieds" page (the virtual page created by the plugin) using the following;

    <?php if ( is_page( 'classifieds' ) ) { ?>
    <?php } else { ?>
     <?php } ?>

    Furthermore, conditional target of the following;

    <?php
    global $post;
    if ( ($post->post_type == 'classifieds') && ! is_category('staff-positions-available') ) { ?>

    Displays to all classifieds pages, not just the classified category of "Staff positions available".

    I assume the target of "is_category('staff-positions-available')" doesn't work since the classifieds category is a CPT category, but codex indicates this should work with CPT. So this is a little confusing.

    I appreciate your help with this matter!
    Thanks.

  • fostermartin

    Hello Ash,

    Your advice pointed me in the right direction.
    I rebuilt my page.php and I have corrected the issue I was having.

    However I am still looking for the correct conditional for the following;

    <?php
    global $post;
    if ( ($post->post_type == 'classifieds') && ! is_category('staff-positions-available') ) { ?>
    <div id="cf-picker">
    <ul>
    <li id="cf-p1"><a href="/cf-categories/staff-positions-available/" title="Find a Job">Find a Job</a></li>
    <li id="cf-p2"><a href="/my-account" title="Post Resume">Post Resume</a></li>
    <li><a href="/classifieds/my-classifieds/" title="Post a Job">Post a Job</a></li>
    </ul>
    </div>
    <?php } else { ?>
    <?php } ?>

    I only want this block to display here;
    http://5dds.fostermartin.net/cf-categories/classifieds/staff-positions-available/

    While not displaying on any other classifieds category.

    Any help in resolving this would be much appreciated.
    Thanks for your time.

  • Michael Bissett

    Hey @fostermartin,

    Do you still have your single-classifieds.php handy? The one that caused the 500 error?

    It would help if we could see the code in full, both for this & the page.php template, can you please send in:

    - In the subject field add "Attn: Michael Bissett”
    - Link back to this thread
    - Include WordPress admin access details
    - Include FTP log-in details
    - Include any relevant URLs for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    https://premium.wpmudev.org/contact/

    Thanks a bunch! :slight_smile:

    Kind Regards,
    Michael

  • Michael Bissett

    Hey @fostermartin, thanks for your patience here! :slight_smile:

    I modified your page.php template, so that instead of using:

    if ( ($post->post_type == 'classifieds') && ! is_category('staff-positions-available') )

    It now uses this:

    if ( is_tax( 'classifieds_categories', 'staff-positions-available') )

    Here's the full code snippet:

    <?php
                      global $post;
                      if ( is_tax( 'classifieds_categories', 'staff-positions-available') ) { ?>
                        <div id="cf-picker">
                        <ul>
                        <li id="cf-p1"><a href="/cf-categories/staff-positions-available/" title="Find a Job">Find a Job</a></li>
                        <li id="cf-p2"><a href="/my-account" title="Post Resume">Post Resume</a></li>
                        <li><a href="/classifieds/my-classifieds/" title="Post a Job">Post a Job</a></li>
                        </ul>
                        </div>
                        <?php } else { ?>
                      <?php } ?>

    In regards to the single-classifieds.php template, what was it you were trying to do? I see that you mentioned that you copied over the single-classifieds.php template that Classifieds has, the error you were getting was this (had to set WP_DEBUG to true to see it):

    Fatal error: Using $this when not in object context in ../wp-content/themes/brew-master/single-classifieds.php on line 12

    Please advise,
    Michael

  • fostermartin

    Hi Michael,

    Thank you for your help with this issue.

    The modification you made isn't displaying the #cf-picker on the staff-positions-available category page.
    The section that is supposed to conditionally display is not displaying.

    In regards to the single-classifieds.php, I am attempting to override the core file by placing it in my theme directory as indicated in the file header.
    I want to be able to customize this page extensively.
    The override does not work as it indicates it should.

  • Michael Bissett

    Hey @fostermartin,

    The modification you made isn't displaying the #cf-picker on the staff-positions-available category page.
    The section that is supposed to conditionally display is not displaying.

    I'm not seeing that the category exists on your site now, have you decided to take it down?

    When it was up there previously, I was seeing that the section you wanted to add was showing up on the category archive page (as requested).

    In regards to the single-classifieds.php, I am attempting to override the core file by placing it in my theme directory as indicated in the file header.
    I want to be able to customize this page extensively.
    The override does not work as it indicates it should.

    Have you tried creating a subfolder called "classifieds" inside your child theme, and inserting the single-classifieds.php file there? That was the solution on another thread:

    https://premium.wpmudev.org/forums/topic/fatal-error-when-updating-single-classifiedsphp-to-theme

    Please advise,
    Michael

  • fostermartin

    Hi Michael,

    I think we have found the end of the rabbit hole!

    global $post;
    if ( is_tax( 'classifieds_categories', 'associatepartnerstaff') ) { ?>

    Is the correct conditional for displaying at a per category level.

    To override the single-classifieds.php file, it does need to be placed within the folder, i.e. "/wp-content/themes/YOUR-THEME/classifieds/single-classifieds.php"

    Along time coming but this solution absolutely works. Thank you very much!

    I have two issues remaining with the plugin however.

    1. I would like to make the my classifieds page a child page of "My Account", when i do this however the virtual page text is displayed until i reparent it to the classifieds page. Is there a method of doing this?

    2. I am attempting to conditionally target the virtual classifieds parent page to display categories and descriptions that I have hard coded. Previously I had been able to do this, but after attempting further customization, this no longer works using the following code;

    if ( is_page( 'classifieds' ) )

    Thank you for your help thus far, it has been invaluable!

  • Michael Bissett

    Hey @fostermartin, glad to hear that you got those two issues sorted out! :slight_smile:

    In regards to your other two questions, those would be best opened as separate threads, as those would be separate issues (we've already gone somewhat off-topic here in this thread already, and that can make things messy).

    Could you do that for me please? :slight_smile:

    https://premium.wpmudev.org/forums/#question

    Thanks a bunch!

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.