Title: Errors and layout issues
Last modified: August 31, 2016

---

# Errors and layout issues

 *  Resolved [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/)
 * I can’t submit articles for approval because I’m getting publishing errors like
   this:
 * > [body] => {“errors”:[{“code”:”INVALID_DOCUMENT”,”keyPath”:[“root”,”components”,”[
   > 6]”,”text”],”message”:”\”text\” was \”\\\”\\\”\” should be not (null or an 
   > empty string)”},{“code”:”INVALID_DOCUMENT”,”keyPath”:[“root”,”components”,”[
   > 6]”],”message”:”no components defined for role=body”},{“code”:”INVALID_DOCUMENT”,”
   > keyPath”:[“root”,”components”,”[8]”,”text”],”message”:”\”text\” was \”\\\”\\\”\”
   > should be not (null or an empty string)”},{“code”:”INVALID_DOCUMENT”,”keyPath”:[“
   > root”,”components”,”[8]”],”message”:”no components defined for role=body”}]}
 * Also have layout issues where the Post’s Title is being placed above the Feature
   Image (Cover) and titles are truncated rather than wrapping in the draft list
   view in Apple Publisher.
    I have yet to work out which file to edit to change
   the how the json file is sent nor how to introduce additional style rules for
   h3 tags etc??
 * [https://wordpress.org/plugins/publish-to-apple-news/](https://wordpress.org/plugins/publish-to-apple-news/)

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/errors-and-layout-issues/page/2/?output_format=md&replies=11)
[→](https://wordpress.org/support/topic/errors-and-layout-issues/page/2/?output_format=md&replies=11)

 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180070)
 * The Apple News plugin uses a built-in template that uses a default component 
   order. Re-ordering certain components (like moving the title below the image)
   is a feature that’s in the queue for development for the next version of the 
   plugin. You can also use the numerous hooks and filters provided by the plugin
   to develop your own custom components or templates. It does require a strong 
   knowledge of the Apple News format, so I suggest reading through their documentation
   thoroughly if you go that route.
 * All body styles are converted to Markdown format which is what Apple News uses.
 * Those errors seem to indicate that the body content is empty. I’d recommend downloading
   the JSON for that post and troubleshooting further in the News Preview tool.
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180104)
 * Thanks Bradford. I’ll look at the News Preview tool.
 * One other query – I mentioned body styles but specifically heading tags and corresponding
   line-heights. In Advanced settings >’heading line height’ seems to affect all
   H tag line-heights. How to override this for eg H3 tags?
 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180107)
 * You’d need to edit the final JSON, there really isn’t a way around that. This
   can be done using the filter `apple_news_get_json`
 * I think we could improve the available filters for a future version though.
 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180108)
 * Another thought would also be to create a custom Heading component class that
   handles this too. You can create your own within your theme and then filter out
   the existing one and insert yours using the filter `apple_news_initialize_components`
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180109)
 * OK, thanks. I’ll look into this.
 *  [Andrew Norcross](https://wordpress.org/support/users/norcross/)
 * (@norcross)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180113)
 * also look at the `apple_news_component_text_styles` filter, which passes all 
   the styles. you can mod any of the existing ones (or add new ones) there.
 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180114)
 * Good call
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180115)
 * Hmmm… might be out of my depth, here.
    You have a ‘title’ component which has
   and uses styles and a ‘heading component that doesn’t use styles (and isn’t supported
   by apple markdown). Where would I add a custom style to H3 tags?
 * Sorry – both components use styles. I’m confused about this directive in the 
   headings class
 *     ```
       *: No markdown because the apple format doesn't support markdown with
       		// textStyle in headings.
       ```
   
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180124)
 * Well – downloaded Apple News preview and no json files can be opened (not even
   examples downloaded from the Apple developer site) and no console logs show up
   so I’m done for now.
 * I’ll await an update to the plugin and see how it goes.
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180135)
 * After more testing, my main layout issue is with images placed within body text.
   No matter how the images are aligned, the paragraphs are always split at the 
   first line. [See this image.](https://www.dropbox.com/s/j09azo4yk4aousc/IMG_7752.png?dl=0)
   
   Could this be to do with the body class and how it manages non-markdownable content–`
   function split_non_markdownable` ?
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180308)
 * Just following up on this to see how I can change heading styles – lineHeight
   and margins.
 * I’ve been looking into the apple_news_component_text_styles filter but cant work
   out how to utilise it. Are we talking about html or json here?
 *     ```
       protected function build() {
       		return apply_filters( 'apple_news_component_text_styles', $this->styles );
       	}
       ```
   
 * I assume I need to access two private functions in the class-heading.php – set_layout
   and set_style or the $styles variable but I can’t work out how to access them.
   I’ve spent a lot of time trying to find answers looking at lots of examples but
   no luck.
 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180309)
 * You shouldn’t need to access the private functions. The filter you specifically
   mentioned takes a PHP array in the format of Apple News JSON.
 * With regards to customizing the layout and styles, the built-in component classes
   create a default layout that has some customization options in the Apple News
   plugin settings. For more advanced customizations, we’ve made it easy to create
   your own version of the component classes and substitute them for the built-in
   versions using the `apple_news_initialize_components` hook: [https://github.com/alleyinteractive/apple-news/blob/master/includes/apple-exporter/class-component-factory.php#L93](https://github.com/alleyinteractive/apple-news/blob/master/includes/apple-exporter/class-component-factory.php#L93)
 * You can also always modify the final JSON output (it’s a PHP array at this point)
   using `apple_news_generate_json`: [https://github.com/alleyinteractive/apple-news/blob/master/includes/apple-exporter/class-exporter.php#L192](https://github.com/alleyinteractive/apple-news/blob/master/includes/apple-exporter/class-exporter.php#L192)
 * Hope that helps!
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180317)
 * I’ve spent a lot of time trying to use the filter hook in my functions.php file–
   apple_news_initialize_components hook – but cant get anything to work.
 * I want to replace the ‘heading’ line of the $Components array here:
    `self::register_component('
   heading' , '\\Apple_Exporter\\Components\\Heading' );` with another class/file
   but unsure how to reference the array in my function as it’s part of the class
   Component_Factory.
 * My latest attempt:
 *     ```
       function change_components($components){ \\How to access Component_Factory::$components
   
       	//$newcomps = new Component_Factory::$components;
   
       	$ns = 'headingtest';
       	$nc = '\\Apple_Exporter\\Components\\Headingtest';
   
       	foreach($components as $comp){
   
       	$comp = str_replace('heading',$ns,$comp);
       	$comp .= str_replace('\\Apple_Exporter\\Components\\Heading',$nc,$comp);
       		return $comp;
       	}
   
       	return $components;
       }
       add_filter('apple_news_initialize_components','change_components');
       ```
   
 * I know you guys are busy with the plain development but any hints would be appreciated.
 *  Plugin Author [Bradford Campeau-Laurion](https://wordpress.org/support/users/potatomaster/)
 * (@potatomaster)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180318)
 * Iterating over an array with a foreach loop creates a copy of the array, unless
   you append the & param to the pointer variable like:
 * `foreach( $components as &$comp ) {`
 * Otherwise anything you do in the loop does not modify the array.
 * That said, a much simpler way to do this is to use the `apple_news_register_component`
   filter in the same class, something like:
 *     ```
       function override_heading( $classname, $shortname ) {
       	if ( 'heading' === $shortname ) {
       		$classname = 'YOUR CLASSNAME GOES HERE';
       	}
   
       	return $classname;
       }
       add_filter( 'apple_news_register_component', 'override_heading', 10, 2 );
       ```
   
 *  Thread Starter [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * (@mitchellau)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/#post-7180319)
 * Thanks Bradford.
    I have this code, below, but I’m getting a blank screen on 
   submitting for publishing (no errors). I have a file called class-headingtest.
   php in the same directory as the other class files.
 *     ```
       function override_heading( $classname, $shortname ) {
       	if ( 'heading' === $shortname ) {
       		$classname = '\\Apple_Exporter\\Components\\Headingtest';
       	}
   
       	return $classname;
       }
       add_filter( 'apple_news_register_component', 'override_heading', 10, 2 );
       ```
   

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/errors-and-layout-issues/page/2/?output_format=md&replies=11)
[→](https://wordpress.org/support/topic/errors-and-layout-issues/page/2/?output_format=md&replies=11)

The topic ‘Errors and layout issues’ is closed to new replies.

 * ![](https://ps.w.org/publish-to-apple-news/assets/icon-256x256.png?rev=3017580)
 * [Publish To Apple News](https://wordpress.org/plugins/publish-to-apple-news/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/publish-to-apple-news/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/publish-to-apple-news/)
 * [Active Topics](https://wordpress.org/support/plugin/publish-to-apple-news/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/publish-to-apple-news/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/publish-to-apple-news/reviews/)

## Tags

 * [Apple News](https://wordpress.org/support/topic-tag/apple-news/)
 * [json](https://wordpress.org/support/topic-tag/json/)

 * 18 replies
 * 3 participants
 * Last reply from: [MitchellAU](https://wordpress.org/support/users/mitchellau/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/errors-and-layout-issues/page/2/#post-7180322)
 * Status: resolved