MitchellAU
Forum Replies Created
-
Forum: Plugins
In reply to: [Instant Articles for WP] Pages Show Up As Instant ArticlesSome more experimentation. After adding
&& ! $query->is_page()to the code below, I still get pages sent to FB Instant articles. Also triedpost__not_inarray if page IDs – still no dice.function instant_articles_query( $query ) { if ( $query->is_main_query() && $query->is_feed( INSTANT_ARTICLES_SLUG ) && ! $query->is_page()) { $query->set( 'orderby', 'modified' ); $query->set( 'posts_per_page', 10 ); $query->set( 'posts_per_rss', 10 ); //$query->set('post__not_in', array(31183, 25781) ); if ( defined( 'INSTANT_ARTICLES_LIMIT_POSTS' ) && INSTANT_ARTICLES_LIMIT_POSTS ) { $query->set( 'date_query', array( array( 'column' => 'post_modified', 'after' => '1 day ago', ), ) ); } } } add_action( 'pre_get_posts', 'instant_articles_query', 10, 1 );Forum: Plugins
In reply to: [Instant Articles for WP] Pages Show Up As Instant ArticlesAny update on this? cant find anywhere in the code that suggests pages will be included in the feed?
Forum: Plugins
In reply to: [Instant Articles for WP] Populate subtitle with custom post metaI’ve just done something similar by adding a custom field to the byline. I’m a novice at this, but I’m guessing that $this should be $post_ID and that $subtitle should be declared global?
function change_ia_subtitle( $subtitle, $post_ID ) { global $subtitle; $subtitle = get_post_meta($post_ID, 'subtitulo', true); return $subtitle; }Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesChanged this
if ( 'heading' === $shortname ) {to thisif($shortname === 'heading') {.
Seems obvious, now. 😉Works a treat. Thanks Bradford.
Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesYes, there would be errors but WP debug mode isn’t reporting anything. Will have to look at hosting. I don’t have any logs in my base directory.
Will get back to you.
Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesThanks 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 );Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesI’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.
Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesJust 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.
Thanks Bradford,
Still learning a bit of this stuff. I also had to replace $post with $post_id and it works.
Thanks for your help and continued development of the plugin.
cheers
MitchellSorry to bring this up again but I’m having problems adding a guest author to the byline.
I have a custom field guest_author that I’m trying to retrieve. So I need to replace this:
$author = ucfirst( get_the_author_meta( 'display_name', $post->post_author ) );with my custom field.I have this in my functions.php. For testing purposes, I’ve simplified the filter to just enter the guest_author and the post_ID.
add_filter('apple_news_exporter_byline', 'custom_author'); function custom_author($byline, $post) { global $post; //$post = get_post($post->ID); if (get_post_meta($post->ID, 'guest_author', true) != '') { $byline = get_post_meta($post->ID, 'guest_author', true); } else { $byline = 'no author'.$post->ID; } return $byline; }I’m not getting the $post->ID so the byline text is always “no author”. As I’m obviously not getting the ID I was wondering how to retrieve it or is there another hook I should be using.
Forum: Plugins
In reply to: [Publish To Apple News] Invalid Document errorHi Bradford,
Yes I’m renaming and downloading images to the folder. Dragging the article.json file to the News Preview window always yields the same message “can’t open the file etc” ‘check the console log for errors’. The console window is empty. According to my version of the app it’s still in beta.Apple support has asked for details about the News Preview problem.
Interestingly, even the sample files that Apple supplies don’t open in News Preview.
Forum: Plugins
In reply to: [Publish To Apple News] Invalid Document errorI’m having limited success using the plugin – it seems to be hit and miss whether I can successfully publish to Apple news.
My main problem is that I cannot use the Apple News Preview app on OSX. The documentation is scant at best. I have looked at all the posts/tips here and elsewhere but News preview will not load the article.json files and no logs are created in the App console.
I will be contacting Apple support on this but thought I’d post here as well.
Thought I’d chime in here, as I’ve had the same issue
I’ve just updated iOS on my iPhone to 9.3 which includes a News app update. It appears to have resolved the image/paragraph problem as my test draft article layout is fixed.
Will test some more articles ASAP
Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesAfter 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.
Could this be to do with the body class and how it manages non-markdownable content –function split_non_markdownable?Forum: Plugins
In reply to: [Publish To Apple News] Errors and layout issuesWell – 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.