Jump to content

Archived

This topic is now archived and is closed to further replies.

glennyboy

Fix Faulty Custom Post Template

Recommended Posts

glennyboy    9
glennyboy

Hi

 

I've experienced a major problem. I was using PL NextBox on a custom post type detail page. As far as I know the php content was fine, but on refreshing / loading the page I get "Oops, There may be an issue loading". problem is that I hadn't created a template for the individual custom post type yet and so it's pulling up an unknown template. I simply can't get rid of the error as there is no template to delete. Very frustrating. Please advise how to reset this particular post type in DMS. Is there a fallback?

 

Best Regards
 
Glennyboy

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

I've tried resetting the permailink to a custom permalink and that didn't work so I'm stuck with a post type with an error that seems impossible to remove?

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

OK Glad to say I fixed this issue by going directly into the database to remove the offending PLNextBox entry. If anyone else has the same sort of issue you can filed Pagelines sections in the database table wp_pl_data_sections. I am using a multisite install so it is format wp_thesiteid_pl_data_sections.

 

Pagelines need more failsafe fallback measures.

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

Thanks for informing us the issue has been resolved and I will also make sure our developers see this topic.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Simon    247
Simon

So what content was in the box that caused the error? Must have been javascript im guessing, or a PHP error.

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

No javascipt involved - leaving just php in this case

Share this post


Link to post
Share on other sites
Simon    247
Simon

ok, and the code was?

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

deleted and updated I'm afraid. It was calling a custom field a the ACF plugin though

Share this post


Link to post
Share on other sites
Simon    247
Simon

I guess we'll never know then ;)

 

The nextbox section does its best to test for PHP errors, but it isn't entirely bullet proof.

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

The php was something like:-

<?php 
 
$term = get_field('taxonomy_field_name');
 
if( $term ): ?>
 
	<h2><?php echo $term->name; ?></h2>
	<p><?php echo $term->description; ?></p>
 
<?php endif; ?>

Minus the staring and ending php tags

Share this post


Link to post
Share on other sites
Simon    247
Simon

Well off the bat, you are not checking if $term is an object.. and opening closing tags just to echo might be an issue too...

 

consider this:

$term = get_field('taxonomy_field_name');

if( is_object( $term ) && isset( $term->name ) && isset( $term->description ) ) {

    printf( '<h2>%s</h2><p>%s</p>', $term->name, $term->description );

}

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

I'm not sure if ACF handles that? The code is directly from their documentation

Share this post


Link to post
Share on other sites
Simon    247
Simon

I have no idea what ACF is, but my code does EXACLY what your code does, but it does it with error checking included. In PHP you have to assume a value is not set, so you must check it is valid before using it.

Share this post


Link to post
Share on other sites
Simon    247
Simon

Ok well whatever it is, my code is the same, uses the same function exactly as yours does.

Share this post


Link to post
Share on other sites
glennyboy    9
glennyboy

If its any consolation I added your code to my CodeBox for use later :-)

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • mno
      By mno+
      In DMS we used to have the section "PLNextBox"that was pretty handy for adding php code in different parts of the page. I used it a lot in global sections like the footer and header to detect what is the current language of the site and based on that output the right string.
      Is the embed section going to support php in the future? are you bringing PLNextBox to PL5? is there another way to work with multiple languages for the global footer and header sections?
       
    • flourishdesignstudio
      By flourishdesignstudio
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
×