Translation of Element in Html doesnt change on the Website (Wordpress) - php

Hello Stackoverflow Community,
I have the following problem:
I have a (Wordpress)Website and am using a nice theme there. My Website is german so I wanted to translate an element from english to german. So I went to the Theme Editor, found the Class and changed "view Profile" to "Profil anschauen". But it seems like that it doesn't update on the website. It's still the same there.
<li class="user-header">
<?php echo get_avatar( um_user( 'ID' ), 84 ); ?>
<p>
<?php echo um_user( 'display_name' ); ?>
<small class="mb-5">#<?php echo um_user( 'user_login' ); ?></small>
Profil anschauen
</p>
</li>
I mean, there nothing else to change, so why does it not update?
Inspect Element on Website:
Website

Related

Tags on homepage grid won't center if the tags do not go over 2 lines

My homepage is in a grid format and each post shows all tags related to that post (ProgressionFantasy). I would like all tags and other taxonomies to be centred. I have used the div align="center" code which centre's the tags, but I've noticed that it only centre's them if there are too many tags to fit on 1 line. As long as at least one of my taxonomies has enough terms to cover 2 lines, then the whole section is centred, however if none of the taxonomies has enough terms to cover more than 1 line then it is left aligned.
Can anyone think of why it might be doing this and how to fix it?
p.s. Yes I know my codes a little messy, I'm still very new to coding and most of this has been snipped together from different areas, whenever I find something that works. The space before div align, is only there because it wouldn't show on here otherwise for some reason ??
EDIT: It appears the problem occurs due to the post-meta class which was part of the original theme coding. Removing this class fixes the alignment problem, but loses all styling for the taxonomies. Any ideas on how to fix this?
CURRENT CODE BELOW
< div align="center">
<div class="post-meta">
<?php if ( 'post' === get_post_type() && cd_index_meta_cat() ) : ?>
<span class="post-category">
<span class= aria-hidden="true"></span>
<span class="screen-reader-text"><?php esc_html_e( 'Categories', 'coldbox' ); ?></span>
<?php echo get_the_term_list( $post->ID, 'format','', ', ', '' );?>
<br>
<br>
<?php the_tags( '<p class="posttag">', ',', '</p>' ); ?>
<?php echo get_the_term_list( $post->ID, 'character_tags','', ', ', '' );?>
</span> <?php endif; ?> </div>
<br>
</div>

How to display user city and state, and profile picture in wordpress

I am making a custom profile page for the users on my WordPress site. I have been able to easily display the username of the logged in user. But I am running into a couple issues:
1) I am having a really hard time finding out how to display the logged in user's city and state. This information is stored in Dashboard/Users/'username' under the shipping address section.
2) I cannot figure out how to display the user's profile picture. From what I have read, user profile pictures are stored on Gravatar's servers...
I am displaying this on a left-sidebar...Here is my code so far for displaying the username
sidebar-profile.php
<div id="sidebar-profile" class="sidebar">
<div>
<h4>
<?php
$current_user = wp_get_current_user();
echo $current_user->user_login;
?>
</h4>
</div>
<?php dynamic_sidebar( 'profile' ); ?>
</div>
I have tried a few different things and all have failed to work.
Also, I am a novice web developer so there may be some errors with my approach to displaying these values.
You should be able to grab the users gravatar image with your above code like so:
<div id="sidebar-profile" class="sidebar">
<div>
<h4>
<?php
$current_user = wp_get_current_user();
echo $current_user->user_login;
echo get_avatar( $current_user->user_email, 32 );
?>
</h4>
</div>
<?php dynamic_sidebar( 'profile' ); ?>
</div>
This will display a <img> tag with the gravatar, there is also additional arguments you can use with the get_avatar() function to allow you to customize the output further: https://codex.wordpress.org/Function_Reference/get_avatar
I'm assuming for the city and state of the user you are using WooCommerce, if so then you should be able to grab this information from the users post meta:
$shippingCity = get_post_meta($current_user->ID, 'shipping_city', true);
$shippingState = get_post_meta($current_user->ID, 'shipping_state', true);

The title from theme options is not showing up

I want to show dynamic title that means user can add his own title from theme options, but it's not going up. My theme options page is working fine and even my title is showing up in the options page ... while unable to show on page.
Here is mine code for theme options.
<!-- Option 2: Custom Heading for banner -->
<tr valign="top">
<th scope="row"><?php _e( 'Heading for page banner' ); ?></th>
<td>
<input id="theme_settings[heading]" type="text" size="36" name="theme_settings[heading]" value="<?php esc_attr_e( $options['heading'] ); ?>" />
<label for="theme_settings[heading]"><?php _e( 'Enter your desired title here' ); ?></label>
</td>
</tr>
It shows a good title like shown below in image theme options page!
Now the problem is that once I use code in my main page it never shows up, while its saved in WordPress as shown in red rectangle in above image.
Here is the code I am using in my main page, that code is being used in 2 pages, index.php and frontpage.php:
<?php if($options['heading']) { ?>
<h1><?php echo $options['heading']; ?></h1>
<?php } else { ?>
<h1>a fresh start for the family</h1>
<?php } ?>
Can any one point out the mistake?
Image removed as I could not upload ... simply means that my theme options allow me to add title in backend and even saved that title but now my page still shows that static title.
If you are not getting your value from database then you can use get_option to simply fetch your value and then you can proceed.
Here is the example code snippet:
<p><?php echo esc_html( sprintf( __( 'Character set: %s', 'textdomain' ), get_option( 'blog_charset' ) ) ); ?></p>
Here is the full WordPress get_option page reference URL ... https://developer.wordpress.org/reference/functions/get_option/

add php inside the short code

Well what I am trying to do is add a barcode to my wordpress sidebar. The plugin used to generate the barcode is called Yeblon
Yeblon Plugin Page
the shortcode used by the plugin is
[yeblonqrcode size="100" url="" class="" style=""]
were url is the place were the generated barcode leads to
The url I want to generate is inserted from the custom fields. I use a plugin called Advanced Custom Fields.
Advanced Custom Fields Plugin Page
the code that displays the link is
<?php the_field("download_(android)" , $post->ID); ?>
So my final code is
<div id="mobile-barcodes-tabs">
<?php $post = $wp_query->post; ?>
<?php
if(get_field('download_(android)')){ ?>
<?php echo do_shortcode('[yeblonqrcode size="100" url="the_field("download_(android)" , $post->ID);" class="" style=""] ');?>
<?php }
?>
</div>
But it is not working I don't know what is the problem I will be glad if you helped me thanks in advance
Build the PHP values beforehand and use string concatenation:
<div id="mobile-barcodes-tabs">
<?php
$post = $wp_query->post;
$the_url = get_field( 'download_(android)' , $post->ID );
if( $the_url ) {
echo do_shortcode( '[yeblonqrcode size="100" url="' . $the_url . '" class="" style=""]' );
}
?>
</div>
PS: You probably noticed that I removed all those unnecessary opening and closing PHP tags.

Wordpress' get_comments() only returns text and no HTML

I am using get_comments() to retrieve the comments of a specific wordpress post in my custom theme. The problem is that there is no HTML inside of the output.
for example when a user adds an URL to a comment, in the admin console it shows as a link but using get_comments() it returns just text.
As there are no filters or other options that covers this on this page: http://codex.wordpress.org/Function_Reference/get_comments I don't quite know what is wrong. Am I supposed to manage that with javascript afterwards?
Thanks for your help guys!
I'd guess you could apply the 'the_content' filter;
<?php foreach (get_comments() as $comment): ?>
<div class="comment">
<?=apply_filters('the_content', $comment->comment_content) ?>
</div>
<?php endforeach; ?>
I'd recommend taking a look at an existing theme's comments.php template file, modifying it to suit your purposes, and then calling it via comments_template().
The theme based on ZURB's Foundation Framework, for example uses wp_list_comments:
<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>
See if that gives you a more formatted output.
You can use this and it'll display the username, date, avatar and all its p tags.
<div class="comments">
<?php $comments_args = array(
// change the title of send button
'label_submit'=>'Send',
// change the title of the reply section
'title_reply'=>'Write a new comment',
// remove "Text or HTML to be displayed after the set of comment fields"
'comment_notes_after' => '',
// redefine your own textarea (the comment body)
'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" aria-required="true" placeholder="Type your comment"></textarea></p>',
);
comment_form($comments_args); ?>
</div>
<div class="comments-form">
<?php
$user_id = get_current_user_id();
$user_specific_comments = get_comments(
array(
'post_id' => YOUR_POST_ID,
)
);
wp_list_comments(
array(
'per_page' => 10,
),
$user_specific_comments
);
?>
</div>

Categories