Have since a small module (wordpress) that does not automatically more language can.
Since WPML finds no string.
$html .= '<li class="weiterlesen">' . $args['readmore_text'] . '</li></ul></div>';
replace . $args['readmore_text'] . to <?php _e( 'readmore', 'tpl' ); ?>
Try below code
$html .= '<li class="weiterlesen">' . __( 'readmore', 'tpl' ) . '</li></ul></div>';
Related
I'm trying changing titles on Wordpress Woocommerce shop page depends on which variation I'm using.
I've found one solution which works perfectly on product pages. I'm stuck now and need to change a little bit the code that will work on shop page too.
Here is the code for the product page:
https://wordpress.org/support/topic/how-to-make-the-title-of-the-product-change-when-choosing-specific-variation/
It works perfectly, you can check the working code here:
http://tattodivi.nhely.hu/product/flower-lily/
I need one more solution which works on Woocommerce shop page too in this link:
http://tattodivi.nhely.hu/
If any of you can help me on this let me know.
Thanks.
The following code might work
jQuery('.products .variable-item').on('click', function(){
if(jQuery(this).parent().hasClass('image-variable-wrapper')){
var title_obj = jQuery(this).parent().parent().parent().parent().parent().find('.woocommerce-loop-product__title');
if(typeof(title_obj.attr('data-title'))=='undefined'){
title_obj.attr('data-title', title_obj.text());
}
title_obj.text(title_obj.data('title')+' - '+jQuery(this).data('value'));
}
});
This snippet will work only if you set default variation beforehand as its in the demo you provide.
//Remove default title
remove_action('woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title',10);
//Add custom title
add_action('woocommerce_shop_loop_item_title','custom_template_loop_product_title',10);
function theme_template_loop_product_title() {
global $product;
if($product->get_type() === 'variable'):
$attributes = $product->get_default_attributes();
if($attributes):
$_title = array();
foreach($attributes as $attribute):
$_title[] .= $attribute.' ';
endforeach;
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() .' '. implode('',$_title).'</h2>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
else:
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h2>';
endif;
else:
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h2>'; endif;
}
I am trying to display a grid list of registered users under specific roles such as subscriber, editor, etc with custom metadata. I've started with this below code but it only displays the avatar and the name when need to display some more data of each user such as website link, description, email.
Here is the code snippet I am using-
function wpb_recently_registered_users() {
global $wpdb;
$recentusers = '<ul class="recently-user">';
$usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
foreach ($usernames as $username) {
if (!$username->user_url) :
$recentusers .= '<li>' . get_avatar($username->user_email, 45) . '' . $username->user_nicename . "</li>";
else :
$recentusers .= '<li>' . get_avatar($username->user_email, 45) . '' . $username->user_nicename . "</li>";
endif;
}
$recentusers .= '</ul>';
return $recentusers;
}
add_shortcode('wpb_newusers', 'wpb_recently_registered_users');
I need to get these user meta key data also -
mepr_email, mepr_your_bio, mepr_youtube_channel
but not sure how to integrate with the above code snippets. Can anyone help me find a better solution, please?
So I am using this code snippet and getting all the required data but I am not sure how to run this as a loop so as soon as a new user register it will get the data like posts query? Sorry I have limited knowledge in this.
'function user_data_code(){
$blogusers = get_users( array( 'search' => 'admin' ) );
// Array of WP_User objects.
foreach ( $blogusers as $user ) {
echo '<span>' . get_avatar($user->user_email, 45) . '</span> <br>';
echo '<span>' . esc_html( $user->user_email ) . '</span> <br>';
echo '<span>' . esc_html( $user->display_name ) . '</span> <br>';
echo '<span>' . esc_html( $user->first_name ) . '</span> <br>';
echo '<span>' . esc_html( $user->mepr_bio ) . '</span> <br>';
echo '<span>' . esc_html( $user->mepr_website_link) . '</span>';
}
}
add_shortcode('wpb_newusers', 'user_data_code');'
I am doing my first every plugin to Wordpress.
How can i insert variable between HTML? I want to insert $today_output between divs?
Have tried all sort of things, but this is too confusing to me.
$today_post_id = 82;
$post_content = get_post($today_post_id);
$today_output = wpautop( $post_content->post_content);
$output = sprintf(
'<div%2$s class="et_pb_code et_pb_module%3$s">
want to add today_output variable here
</div> <!-- .et_pb_today -->',
$this->shortcode_content,
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
);
return $output;
Thanks,
Ville
Maybe try it using string concatenation instead like this:
<?php
$output = '<div class="' . $classname . '">' .
'<div>' . $content . '</div>' .
'</div>';
?>
Here's the page in question: http://www.affordableonlinedegrees.net/blog/
I can style the links just fine—that's not my issue. It’s the text and double-angle quotes I’d like to be able to change to something custom.
In genesis/lib/structure/post.php there’s the below function. How do I edit this properly as a child theme file?
And more specifically, how would I change the ascii double angle quotes ( « and » ) to something of my choice? i.e. a custom background image like an arrow?
function genesis_prev_next_posts_nav() {
$prev_link = get_previous_posts_link( apply_filters( 'genesis_prev_link_text', '«' . __( 'Previous Page', 'genesis' ) ) );
$next_link = get_next_posts_link( apply_filters( 'genesis_next_link_text', __( 'Next Page', 'genesis' ) . '»' ) );
$prev = $prev_link ? '<div class="pagination-previous alignleft">' . $prev_link . '</div>' : '';
$next = $next_link ? '<div class="pagination-next alignright">' . $next_link . '</div>' : '';
$nav = genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div class="navigation">',
'context' => 'archive-pagination',
'echo' => false,
) );
$nav .= $prev;
$nav .= $next;
$nav .= '</div>';
if ( $prev || $next )
echo $nav;
}
I assumed you are using version 2.0 and up. Add codes below to your child theme functions.php. I included icons to change wp default pre/nextlabel, change whatever you want.
add_action('genesis_entry_footer', 'custom_pagination_links', 15 );
function custom_pagination_links() {
if( !is_single() )
return;
previous_post_link('<span class="single-post-nav previous-post-link">%link</span>', '<i class=\'fa fa-arrow-circle-o-left\'></i> ' . get_previous_post_link('%title') , FALSE);
next_post_link('<span class="single-post-nav next-post-link">%link</span>', get_next_post_link('%title') . ' <i class=\'fa fa-arrow-circle-o-right\'></i>' , FALSE);
}
The rest job is styling, it's up to you.
best regards,
dnb
I'm relatively new to PHP and don't even really know how to ask the question for which i need help with, so please excuse my lack of technical knowledge - or referring to terms correctly for that matter.
I cannot figure out a way to add the "if(function_exists("the_ratings"))" code below to a string as in the PHP i have below. I know that the way it is below is not correct, but i've placed it there to show how and where i need it to display - help is greatly appreciated.
function latestreleases() {
$args = array( 'posts_per_page' => 30, 'cat' => '-1, -2' );
$last_5_posts_query = new WP_Query( $args );
while($last_5_posts_query->have_posts()) :
$last_5_posts_query->the_post();
$link = get_permalink();
$title = get_the_title();
$description = excerpt(16);
$details = 'Watch ';
$readmore = 'Read more...';
$content .= '<div class="all-latest-movies">';
$content .= '<h3>'.$title.'</h3>';
$content .= '<div class="thumbnail"><a href=" '.$link. ' ">'
. get_the_post_thumbnail( null, "home-movie-thumbnail")
. '</a></div>';
$content .= '<div class="description">' .$description. ' <a href= '.$link.' >' .$readmore. '</div>';
$content .= '<div class="view-listing"><a href= '.$link.' target="_blank" >' .$details. $title. '</a></div>';
$content .= '<div class="ratings">' if(function_exists("the_ratings")) { the_ratings(); } '</div>';
$content .= '</div><!-- .fetured-movies -->';
endwhile;
return $content;
}
add_shortcode('LatestReleases', 'latestreleases' );
Use a ternary operator:
$content .= '<div class="ratings">'. ( function_exists("the_ratings") ? the_ratings() : '' ) .'</div>';
If you want to do it inline you can use the ternary operator
$content .= '<div class="ratings">'.(function_exists("the_ratings")?the_ratings():'').'</div>';
If you want to use the if syntax
$content .= '<div class="ratings">';
if(function_exists("the_ratings")){
$content.=the_ratings();
}
$content.='</div>';