This started out as a Question, but I sort of made it work. I am sharing it for anyone who needs to know. Or maybe there is a better way?
I'd like to show a welcome message on the home page. Should be placed in the upper left corner.
This is what I did:
add_action( 'storefront_header', 'pfn_userinheader',1);
function pfn_userinheader() {
?>
<span class="pfn_great_header2"> Hello! blablabla</span>
<?php
}
Now the text is placed where the secondary menu. More like top, right of middle. I have no idea why just there. Anyway, I would like it to be placed in the top left corner.
This is my css:
.pfn_great_header2{
position: absolute !important;
left: 0;
top:0;
width: 10% !important;
color: #0071A1;
}
It works. Is it a good way of doing this?
I have something similar on my site but it displays a different message if the customer is already logged in.
If you wanted to do this, you could use something like this:
add_action( 'storefront_header', 'pfn_userinheader',1);
function pfn_userinheader() {
if ( is_user_logged_in() ) {
echo '<span class="pfn_great_header2">Welcome back <?php $current_user = wp_get_current_user(); echo $current_user->user_firstname; ?>!</span>';
}
elseif {
echo '<span class="pfn_great_header2"> Hello! blablabla</span>';
}
}
Related
I am using gutenberg with wordpress and the sidebar where I can edit the blocks is squeezed to the right, making it impossible for me to edit it:
As you can see in the image, the sidebar is shown partially on the screen and I canĀ“t move to the right.
Here are some things I tried:
1 - Work with another browser (Chrome and Edge). It did not work.
2 - Edditing the code in the plugin (Twenty Twenty), stylesheet in Gutenberg and Stackable plugin:
'mode' => 'edit'
//------------------------------------------------
// Admin CSS
//------------------------------------------------
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo
'<style>
.wp-block {max-width: 900px;}
</style>';
}
As explained in: https://support.advancedcustomfields.com/forums/topic/acf-blocks-cramped-in-right-sidebar-of-editor/
Nothing of these worked. Does anyone have a clue?
Tks
Try to overwrite the css box with this code:
.interface-complementary-area {
width: 380px !important;
}
Or in your theme functions.php add this:
// Wider sidebar on gutenberg backend
function my_wider_sidebar() {
echo
'<style>
.interface-complementary-area{ width: 450px !important; }
</style>';
}
add_action('admin_head', 'my_wider_sidebar');
I am attempting to add text beneath the product gallery images of my Wordpress Woo-commerce site.
I have attempted to use the general scripts found online:
add_action( 'woocommerce_after_single_product_summary' , 'bbloomer_add_below_prod_gallery', 5 );
function bbloomer_add_below_prod_gallery() {
echo '<div class="woocommerce-product-gallery" style="background: #fdfd5a; padding: 1em 2em">';
echo '<span>THIS IS A TEST. YOU CAN ADD TEXT, IMAGES AND ANY HTML</span>';
echo '</div>';
}
You can see in the following screenshot that the text appears here and not beneath the actual image
The website link this is referencing can be found at: https://www.tattiniboots.com/product/retriever/
Update:
After trying the proposed solution below, the div text shows all the way at the bottom:
I am attempting to get this div to appear here:
The link I am working at is found here: https://www.tattiniboots.com/product/terranova/
You need to add style clear:both in your div. check the below code.
add_action( 'woocommerce_after_single_product_summary' , 'bbloomer_add_below_prod_gallery', 5 );
function bbloomer_add_below_prod_gallery() {
echo '<div class="woocommerce-product-gallery" style="background: #fdfd5a; padding: 1em 2em; clear:both;">';
echo '<span>THIS IS A TEST. YOU CAN ADD TEXT, IMAGES AND ANY HTML</span>';
echo '</div>';
}
I have some PHP which will output a set of images.If I write it this way
foreach( $data as $inform ) {
{if (isset($inform['file1'])) {
echo '<img src="'.$inform['file1'].'"><br><br>';
}
}
It will display the 4 different images in the array $inform['file1'] with 2 line breaks in between each, but if I want to position them on the page like this
foreach( $data as $inform ) {
if ( isset( $inform['file1'] ) ) {
echo '<div style="position:absolute; top:400px;"><img src="'.$inform['file1'].'"><br><br>
</div>';
}}
Then it displays all 4 images on top of each other, but in the right location.
I've tried styling it in css and nothing works. Can anybody help a newbie learn this?
Thanks in advance.
It's nothing to do with your foreach loop. You're literally telling the images to go on top of each other, so that's what they are doing. If you would like to add spacing to the top, put a container div around the images and do a margin-top: 400px;.
Your biggest problems here are:
You haven't explained what you want to achieve, and
You are mixing in PHP which is making a relatively simply problem seem harder to solve
The styling and positioning of elements should be managed through CSS (preferably not inline CSS).
Your PHP should be:
if( count( $data ) ){
echo '<div class="file1_container">';
# If there are elements in the $data array
foreach( $data as $inform ){
if( isset( $inform['file1'] ) ){
echo '<img src="'.$inform['file1'].'" />';
}
}
echo '</div>';
}else{
# No elements in the $data array
}
Your CSS could then be something like:
.file1_container {
position:absolute;
left:0;top:400px;right:0;
text-align:center;
}
This will position a DIV containing all the images at 400px from the origin, and the IMGs within it will be on the same horizontal line, aligned to the centre of the DIV.
Your practice is bad, but if you must:
foreach($data as $inform){
if(isset($inform['file1'])) {
echo "<div><img src='{$inform['file1']}' /></div><br /><br />";
}
}
Of course, this would add two breaks after the last one as well. You cannot have multiple items in different places using the same position:absolute, since they will all be relative to the last position:relative. Regardless, you should use CSS.
#PHP
foreach($data as $inform){
if(isset($inform['file1'])) {.
echo "<div class='someClass'><img src='{$inform['file1']}' /></div";
}
}
/*CSS*/
.someClass{
margin-top:10px;
}
I'd like to add a video tutorial for registered users to my dashboard in wordpress. I tried this code:
`<style type="text/css">
.postbox,
.postbox div.handlediv,
.postbox h3.hndle {
background: none;
border: none;
}
</style>
<?php
/* add content */
function customContent() {
echo ' http://www.youtube.com/watch?v=rArpyMXT2ew ';
}
/* add widget */
function add_customDashboardWidget() {
wp_add_dashboard_widget('wp_dashboard_widget', 'Custom Content', 'customContent');
}
/* add action */
add_action('wp_dashboard_setup', 'add_customDashboardWidget' );
?>`
but it only shows the line, not the actual video. What to do?
If you don't feel like coding, and you want to be able to easily add more videos and adjust which roles can see them, I just released a plugin that does that super easily. It's lightweight and simple at the moment, but it definitely does the trick.
https://wordpress.org/plugins/video-dashboard/
I've noticed that on some product pages of my site (but not all) I'm getting a strange issue where one of the product images appears in the row below the one it's meant to.
So on some pages the 'People who bought this also purchased...' images, on the last line one of the products drops down a line and is obviously out of place.
http://tinyurl.com/cs6d3q5
but most other pages are fine!
http://tinyurl.com/clwq3dz
I can't figure out whats the problem. As far as I can see they should both act the same way. Can anyone enlighten me and also tell me how they debugged it? I use Firebug and developer tools on FF but they don't seem as useful as they once did
thanks
here's the code used to create it:
if($also_purchased_products->RecordCount() > 0) {
echo '<div style="clear:both"></div>';
echo '<div class="sideboxHeading">People who bought this also purchased...</div> <div class="ProdInfoDotSpacer"></div>';
while (!$also_purchased_products->EOF) {
$also_purchased_products->fields['products_name'] = zen_get_products_name($also_purchased_products->fields['products_id']);
echo '<div class="alsoPurchasedWrapper">';
echo '' . zen_image(DIR_WS_IMAGES . $also_purchased_products->fields['products_image'], $also_purchased_products->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '<br />';
echo '' . $also_purchased_products->fields['products_name'] . '';
echo '</div>';
$also_purchased_products->MoveNext();
}
}
its because
Black/Sage Guinness harp knit
here Black/Sage Guinness harp knit scarf is long try sorting it
The problem appears when the previous item text link is more than one line long. You can truncate it, as NullPointer says, or set a height on .alsoPurchasedWrapper:
.alsoPurchasedWrapper {
float: left;
width: 150px;
margin: 5px 0px 10px 20px;
height: 170px;
}