I have helpers.php like this:
<?php
namespace App;
function get_article_data( int $article_id, $excerpt_length = 20 ) {
if ( empty( $article_id ) ) {
return array();
}
$full_excerpt = wp_strip_all_tags( excerpt_remove_blocks( htmlspecialchars_decode( get_the_excerpt( $article_id ) ) ) );
$particle_excerpt = wp_trim_words(
$full_excerpt,
$excerpt_length,
'...'
);
return array(
'ID' => $article_id,
'title' => html_entity_decode( get_the_title( $article_id ) ),
'link' => get_permalink( $article_id ),
'category' => get_article_primary_category( $article_id ),
'image' => get_article_thumbnail( $article_id, 'full' ),
'date_time' => get_the_date( 'M j, Y g:i A', $article_id ),
'excerpt' => strip_shortcodes( $particle_excerpt ?: wp_trim_excerpt( $particle_excerpt, $article_id ) ),
'full_excerpt' => strip_shortcodes( $full_excerpt ?: wp_trim_excerpt( $full_excerpt, $article_id ) ),
'author' => get_article_author( $article_id ),
);
}
and App.php like this:
<?php
namespace App\View\Composers;
use Roots\Acorn\View\Composer;
use function App\get_article_data;
class App extends Composer {
public static function articlePost( $post_id ) {
return get_article_data( $post_id );
}
and in blade file:
<div class="category">
@while (have_posts())
@php the_post(); $article_post = App\View\Composers\App::articlePost(get_the_ID());
@endphp
@endwhile
</div>
and the browser has error like this:
lass "App\App" not found (View: /Volumes......... list.blade.php) (500 Internal Server Error)
I have not a Wordpress developer, and a long time ago I have not work with wordpress and sage. Please help me. Thank you so much!