Tagged: x
-
AuthorPosts
-
November 3, 2016 at 3:14 am #1242048
nathansjcorpParticipantHi, the recent post is showing the excerpt current length (100)on my english page but my code is not working on the chinese pages.
http://chenhsong.com/customer_success_stories/?lang=zh-hans
http://chenhsong.com/customer_success_storiesIf i add some english to a chinese post then it works fine. I can only assume that the {‘<span class=”x-recent-posts-excerpt”>’ . strip_tags(excerpt(100)) . ‘</span>’} is not working for chinese characters.
November 3, 2016 at 3:16 am #1242049
nathansjcorpParticipantThis is my code:
November 3, 2016 at 3:17 am #1242050
nathansjcorpParticipant// =============================================================================
// Custom Excerpt Length – Call: echo excerpt($length);
// =============================================================================function excerpt($limit) {
$excerpt = explode(‘ ‘, get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(” “,$excerpt).’.’;
} else {
$excerpt = implode(” “,$excerpt);
}
// $excerpt = preg_replace(‘\[[^\]]*\]‘,”,$excerpt);
return $excerpt;
}// =============================================================================
// Add Excerpt to Recent Posts -> [x_recent_posts]
// =============================================================================function x_shortcode_recent_posts_excerpt( $atts ) {
extract( shortcode_atts( array(
‘id’ => ”,
‘class’ => ”,
‘style’ => ”,
‘type’ => ‘post’,
‘count’ => ”,
‘category’ => ”,
‘offset’ => ”,
‘orientation’ => ”,
‘no_image’ => ”,
‘fade’ => ”
), $atts, ‘x_recent_posts’ ) );$allowed_post_types = apply_filters( ‘cs_recent_posts_post_types’, array( ‘post’ => ‘post’ ) );
$type = ( isset( $allowed_post_types[$type] ) ) ? $allowed_post_types[$type] : ‘post’;$id = ( $id != ” ) ? ‘id=”‘ . esc_attr( $id ) . ‘”‘ : ”;
$class = ( $class != ” ) ? ‘x-recent-posts cf ‘ . esc_attr( $class ) : ‘x-recent-posts cf’;
$style = ( $style != ” ) ? ‘style=”‘ . $style . ‘”‘ : ”;
$count = ( $count != ” ) ? $count : 3;
$category = ( $category != ” ) ? $category : ”;
$category_type = ( $type == ‘post’ ) ? ‘category_name’ : ‘portfolio-category’;
$offset = ( $offset != ” ) ? $offset : 0;
$orientation = ( $orientation != ” ) ? ‘ ‘ . $orientation : ‘ horizontal’;
$no_image = ( $no_image == ‘true’ ) ? $no_image : ”;
$fade = ( $fade == ‘true’ ) ? $fade : ‘false’;$js_params = array(
‘fade’ => ( $fade == ‘true’ )
);$data = cs_generate_data_attributes( ‘recent_posts’, $js_params );
$output = “<div {$id} class=\”{$class}{$orientation}\” {$style} {$data} data-fade=\”{$fade}\” >”;
$q = new WP_Query( array(
‘orderby’ => ‘date’,
‘post_type’ => “{$type}”,
‘posts_per_page’ => “{$count}”,
‘offset’ => “{$offset}”,
“{$category_type}” => “{$category}”,
‘ignore_sticky_posts’ => true
) );if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
if ( $no_image == ‘true’ ) {
$image_output = ”;
$image_output_class = ‘no-image’;
} else {
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), ‘entry-cropped’ );
$bg_image = ( $image[0] != ” ) ? ‘ style=”background-image: url(‘ . $image[0] . ‘);”‘ : ”;
$image_output = ‘<div class=”x-recent-posts-img”‘ . $bg_image . ‘></div>’;
$image_output_class = ‘with-image’;
}endwhile; endif; wp_reset_postdata();
$output .= ‘</div>’;
return $output;
}add_action(‘wp_head’, ‘update_x_recent_posts_to_v2’);
function update_x_recent_posts_to_v2() {
remove_shortcode( ‘x_recent_posts’ );
add_shortcode( ‘x_recent_posts’, ‘x_shortcode_recent_posts_excerpt’ );
}November 3, 2016 at 3:27 am #1242052
nathansjcorpParticipantThis reply has been marked as private.November 3, 2016 at 4:16 am #1242100
Rue NelModeratorHello There,
Thanks for writing in and the very detailed information. Please make sure that both of the English posts and the Chinese post has a an excerpt. Did you created the posts in Cornerstone? If that is the case, this is why you are not seeing any excerpt because shortcodes and Cornerstone formatting codes will be strip off in the excerpt. Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts here: https://codex.wordpress.org/Excerpt.
To display the excerpt properly, you have to use the manual excerpts. To add an excerpt to a post, simply write one in the Excerpt field under the post edit box. Please see the screenshot below: http://prntscr.com/9j98do
Hope this helps.
November 3, 2016 at 4:28 am #1242103
nathansjcorpParticipantHi, no that does not help.
I added my code so that i don’t need to use the “manual excerpt”
This works fine in English where it picks up the first 100 characters of my content.
If you look at the post”high-end-medical-equipment-part-molding” in the back end you can clearly see that there is no “manual excerpt”November 3, 2016 at 7:17 am #1242254
ChristianModeratorYes, there is no excerpt. You need to manually write it in the Excerpt box (see attachment)
Thanks.
November 3, 2016 at 8:54 am #1242342
nathansjcorpParticipantI’m sorry, but if you look at the links i sent:
http://chenhsong.com/customer_success_stories/?lang=zh-hans
http://chenhsong.com/customer_success_storiesyou will see that there is some text under the title of each “recent post”.
right??
Now i’m calling that text “excerpt” but you can also call it “beginning of content text” or whatever.
and as far as i know the code that i put in “functions php” allows that “beginning of content text/ excerpt” to be displayed through the “recent post shortcode”Now the problem is that it is not working correctly for chinese characters as made obvious on this page:
http://chenhsong.com/customer_success_stories/?lang=zh-hansPlease don’t tell me about “manual excerpt” as i do not intent to use it, i am hoping for (“automatic excerpt/ automatic display of the first few lines of text”)in my post” which has been working just fine for the last month in English but has a problem in chinese.
thanks.
November 3, 2016 at 10:13 am #1242498
ChristianModeratorI see. Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You might want to contact our trusted partners who caters X setup and customization needs. Please see https://community.theme.co/custom-development/. Thanks for understanding. Take care!
November 4, 2016 at 2:00 am #1243469
nathansjcorpParticipantOk no worries!
Here is a similar problem that should fall under your scope of support:
Under Appearance>customize> blog > content> the excerpt length is not working for chinese.
http://chenhsong.com/11.3bk/category/customer-success-stories-ch/?lang=zh-hans
http://chenhsong.com/11.3bk/category/case-studies/customer-success-stories/
my excerpt length is set to 10
I assume you should fix this as this is a function within your customizer?
Unless Xtheme does not support asian fonts?Please go ahead, and turn content off and on, change length ,edit the post in question, etc… this is a backup version.so you can do what you want with it.
November 4, 2016 at 2:02 am #1243470
nathansjcorpParticipantIf you can’t fix it could you please offer me a hack/ quick fix?
November 4, 2016 at 4:27 am #1243552
Paul RModeratorHi,
You can add manual excerpts to your posts.
Please see screenshot – http://screencast.com/t/ya8A0ZBmclN
Hope that helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1242048 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
