The title from theme options is not showing up - php

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/

Related

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

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

Change product category heading tag for shortcode ux_product_categories on Flatsome - Woocommerce

I'm looking to change heading tag (currently H5) for product categories displaying on home page. These categories are displayed on home page by using an element named ux_product_categories on Flatsome theme.
It seems to be a shortcode. So I looked at product_categories.php file in wp-content/themes/flatsome/inc/shortcodes.
Indeed, I found H5 heading tag, however, when I change it (by putting the modified file with the same path in child theme)... Nothing happens, product categories have still H5 heading tag.
What do I missed ?
Here's the code I changed (replacing "h5" by "p") :
<div class="box-text <?php echo implode(' ', $classes_text); ?>" <?php echo get_shortcode_inline_css($css_args); ?>>
<div class="box-text-inner">
<h5 class="uppercase header-title">
<?php echo $category->name; ?>
</h5>

How to enable images gallery in WordPress

I am trying to enable the function of images to show in a gallery in a post.
I have tried to just do a gallery the "normal" way in wordpress by uploading images, picking the ones I need and putting them into the post.
$post_id = 83;
$queried_post = get_post($post_id);
$title = $queried_post->post_title; ?>
<div id="gallery" class="section-top">
<h1 class="section-heading"> <?php echo $title; ?></h1>
<p class="center-find"><?php echo $queried_post->post_content;?></p>
</div>
I need to be able to show the gallery on the website. When I use the shortcode from the gallery of random pics I have checked off, I can see the images in the post, BUT when I enter my website on the front-page.php, all I get is the actually shortcode displayed and no images.
If I open the post as a "view post", the gallery is displayed, so I imagine that I am missing something in my code to get the images on the front page.
If I use the short code directly in front-page.php, I get the gallery as well, but then my users can't make the gallery like they want it to look like and would have to manually edit the template files themselves and they know nothing about coding.
You should apply a filter to the post content if you want it to pass the shortcode. You might also want to use get_the_title instead of the post object.
$post_id = 83;
$queried_post = get_post($post_id);
$content = apply_filters( 'the_content', $queried_post->post_content );
$title = get_the_title($post_id);
<div id="gallery" class="section-top">
<h1 class="section-heading"> <?php echo $title; ?></h1>
<p class="center-find"><?php echo $content; ?></p>
</div>

Displaying by default shipping fields on checkout page

On my WooCommerce checkout page, I am selling only one product. The checkout page is showing this product and there is ckeckbox next to it, to show the shipping details, when clicked. This is on the default form-checkout.php WooCommerce template.
I would like to have this ckeckbox always selected, to show billing details by default.
I have tried to set:
$checkout = 1;
With no luck so far. The radio button is displayed by the following hook:
<?php do_action( 'woocommerce_checkout_before_customer_details'); ?>
Any help letting me know how I can achieve this will be very helpful.
Thanks.
If you look to the code of checkout/form-shipping.php WooCommerce template, inside the <h3> tag, where the checkbox code is located, there is woocommerce_ship_to_different_address_checked hook that you can use to achieve that. Here is an extract of this code template, that shows it:
?>
<div class="woocommerce-shipping-fields">
<?php if ( true === WC()->cart->needs_shipping_address() ) : ?>
<h3 id="ship-to-different-address">
<label for="ship-to-different-address-checkbox" class="checkbox"><?php _e( 'Ship to a different address?', 'woocommerce' ); ?></label>
<input id="ship-to-different-address-checkbox" class="input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" />
</h3>
<div class="shipping_address">
So you can use this hook this way, to get this checkbox always selected and displays billing details:
add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true');
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
The code is tested and fully functional.

WordPress multiple-submenu

What's the best way to make multiply-page menu?
For example Category1 -> Article -> Full article text?
Not dropdown menu.
There's site example: http://fl.jetcode.lv/service.html
There are on page "Услуги" (Services), list with point's (Обслуживание windows, Подключение интернета, Сборка компьютеров, Чистка вирусов, ...)
When i click one of them (for example 'Обслуживание windows'('Maintenance windows')), i need to get page with points of that category like Установка Windows XP /Vista /7 /8 / W.S 2003,2008 (Installing Windows), Установка Linux (Installing Linux). And each Category have their own list of that text. So what's the best way to make that?
By steps:
1. I'm here: http://fl.jetcode.lv/index.html
2. I click on 'Обслуживание windows', and go to that page http://fl.jetcode.lv/service.html
3. Now i see a list with services on that category
4. Click on 'Полное описание', under 'Установка Windows XP /Vista /7 /8 / W.S 2003,2008'
5. And get to that page http://fl.jetcode.lv/service_inside.html
So how i can structure that's menu with WordPress ?
I've created a Posts with first categories (Category1), then i added it to Appearance->Menus, and get that list on page. Now i can manage their content in post, but it will be hard for end-user. So i trying to make list with second-category in post, and stucked. So can somebody please advice how it correctly/better to do ?
Thanks!
To put this simply,
You won't be needed to change anything to header but in category.php.
Instead of including the <section id="menu"> in the header put it on categories.php then to the usual get post contents and you are done.
The logic isn't in the menu but the flow of how you call each file/element.
This is the sample structure in category.php
<h1 class="post-title"><?php single_cat_title(); ?></h1>
<!-- Display all posts under specific Category -->
<?php while(have_posts()): the_post(); ?>
<hr />
<div id="category-post">
<!-- Display the Post Title -->
<h1><?php the_title(); ?></h1>
<!-- Display the Date & Time of Post -->
<p class="post-date">Posted on <span><?php the_time('F j, Y'); ?></span></p>
<!-- Checks if the post has Featured Image, else will load
the default thumbnail called post-thumb.jpg.
Delete ELSE CLAUSE to remove default thumbnail feature.
-->
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( add_image_size( 'post-thumbnail'), array( 'class' => "post-thumb" ) );
}
else {
echo '<img class="post-thumb wp-post-image" src="';
echo bloginfo( 'stylesheet_directory' );
echo '/_/img/post-thumb.jpg" />';
}
?>
<!-- Display the excerpt if specified IF NOT, will display the
first 20 words in the actual content.
See functions.php for the excerpt lenght setting.
-->
<div class="category-content">
<?php the_excerpt();?>
</div>
<!-- Displays a link to the actual post -->
<a class= "category-read" href="<?php echo get_permalink() ?>">Read</a>
</div>
<?php endwhile; ?>
<!-- Displays the link for NEXT and PREVIOUS entries.
By default, only 10 posts per page can be loaded.
See [Settings > Reading] in Wordpress Panel to configure
-->
<div id='paging'>
<?php next_posts_link('« Older Entries ') ?>
|
<?php previous_posts_link(' Newer Entries »') ?>
</div>

Categories