sebastian78do
Forum Replies Created
-
Forum: Plugins
In reply to: [AMP for WP - Accelerated Mobile Pages] AMP pages and seperate blog rollHello again, thank you for your quick reply. What about a temporary workaround via a shortcode in functions.php?
In the following example I used the loop of Design 1. Currently it doesn’t work because I don’t know how to replace ‘$this’ with a proper object.
function ampblog( $atts ) {
global $redux_builder_amp;
extract( shortcode_atts( array (
‘paged’ => 1,
‘exclude_ids’ => ”
), $atts ) );$args = array(
‘post_type’ => ‘post’,
‘orderby’ => ‘date’,
‘paged’ => esc_attr($paged),
‘post__not_in’ => $exclude_ids,
‘has_password’ => false ,
‘post_status’=> ‘publish’
);
$filtered_args = apply_filters(‘ampforwp_query_args’, $args);
$q = new WP_Query( $filtered_args ); ?><?php if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post(); ?>
<div class=”amp-wp-content amp-wp-article-header amp-loop-list”><h1 class=”amp-wp-title”>
<?php $ampforwp_post_url = get_permalink(); ?>
“><?php the_title() ?>
</h1><div class=”amp-wp-content-loop”>
<div class=”amp-wp-meta”>
<?php $this->load_parts( apply_filters( ‘amp_post_template_meta_parts’, array( ‘meta-author’) ) ); ?>
<time> <?php
printf( _x( ‘%1$s ‘. $redux_builder_amp[‘amp-translator-ago-date-text’], ‘%2$s = human-readable time difference’, ‘wpdocs_textdomain’ ),
human_time_diff( get_the_time( ‘U’ ),
current_time( ‘timestamp’ ) ) ); ?>
</time>
</div><?php if ( has_post_thumbnail() ) { ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, ‘thumbnail’, true);
$thumb_url = $thumb_url_array[0];
?>
<div class=”home-post-image”>
“>
<amp-img
src=<?php echo $thumb_url ?>
<?php if( $redux_builder_amp[‘ampforwp-homepage-posts-image-modify-size’] ) { ?>
width=<?php global $redux_builder_amp; echo $redux_builder_amp[‘ampforwp-homepage-posts-design-1-2-width’] ?>
height=<?php global $redux_builder_amp; echo $redux_builder_amp[‘ampforwp-homepage-posts-design-1-2-height’] ?>
<?php } else { ?>
width=100
height=75
<?php } ?>
></amp-img>
</div>
<?php }
if(has_excerpt()){
$content = get_the_excerpt();
}else{
$content = get_the_content();
} ?>
<p><?php echo wp_trim_words( strip_shortcodes( $content ) , ’20’ ); ?></p>
</div>
</div>
<?php endwhile; ?><div class=”amp-wp-content pagination-holder”>
<div id=”pagination”>
<div class=”next”><?php next_posts_link( $redux_builder_amp[‘amp-translator-next-text’]. ‘ »’, 0 ) ?></div>
<div class=”prev”><?php previous_posts_link( ‘« ‘. $redux_builder_amp[‘amp-translator-previous-text’] ); ?></div>
<div class=”clearfix”></div>
</div></div>
<?php endif;
}
add_shortcode (‘ampblog’, ‘ampblog’ );- This reply was modified 7 years, 8 months ago by sebastian78do.
Hi, I got this code from here: https://github.com/Automattic/amp-wp
I also installed the Automattic AMP-Plugin and thought this might work,
because it uses your plugin as base.I want to hide the author section via PHP. How can I achieve this.
I don’t want to use CSS in this case. Less code, faster loading :o)It would be great if you could provide custom templates in future releases.
Forum: Plugins
In reply to: [AMP for WP - Accelerated Mobile Pages] AMP pages and seperate blog rollHello, exactly. How can I display the latest posts on a seperate page e.g. /blog as already on my homepage? I enabled Homepage Support and defined a Frontpage.
I haven’t found any settings to choose a blog page.