I had created a Wordpress news website. There are many sharing options implemented! I added WhatsApp and send the URL to WhatsApp and share to WhatsApp! The issue is, initially the post image is shown when I share the link in WhatsApp. But now the image is not showing while I share the link in WhatsApp! There are no issues while sharing on facebook! When I inspect the page source WordPress automatically gives og:image as the post feature image! But it does not show up in WhatsApp. But when I copy paste the same og:image to header.php I WordPress it works perfectly! Initially, I thought of the size problem while later I found out that size is as per the og:image meta tag standard.
Here i post the single.php code:
<?php
/**
* NewsGamer Theme
*
* Theme by: MipThemes
* http://themes.mipdesign.com
*
* Our portfolio: http://themeforest.net/user/mip/portfolio
* Thanks for using our theme!
*
*/
// load header
get_header();
// Get Page properties
$mip_current_page = new MipThemeFramework_Page();
// Update Post View
MipThemeFramework_Post_Views::update_post_views($post->ID);
// Load Custom post headers
get_template_part( 'elements/parts/post-header-'. $mip_current_page->page_template .'' );
?>
<!-- start:post-info-bar -->
<?php if ($mip_current_page->enable_post_info_bar) get_template_part( 'elements/post-info-bar' ); ?>
<!-- end:post-info-bar -->
<!-- start:page content -->
<div id="page-content" class="<?php echo esc_attr($mip_current_page->page_template_class); ?> clearfix">
<?php
//get sidebar
if ( ($mip_current_page->page_sidebar_template == 'left-sidebar')&&(!wp_is_mobile()) ) get_sidebar();
?>
<!-- start:main -->
<div id="main" class="main article">
<!-- start:article post -->
<article id="post-<?php echo esc_attr($post->ID); ?>" <?php post_class('article-post clearfix'); ?> <?php echo MipThemeFramework_Util::get_item_scope( $mip_current_page->review_post ); ?>>
<?php
if (have_posts()) :
// Get Template
get_template_part( 'elements/'. $mip_current_page->page_template .'' );
else :
// No Posts
esc_html_e('No posts.', 'newsgamer');
endif;
?>
</article>
<!-- end:article post -->
</div>
<!-- end:main -->
<?php
//get sidebar
if ( ($mip_current_page->page_sidebar_template == 'right-sidebar')||( ($mip_current_page->page_sidebar_template == 'left-sidebar')&&(wp_is_mobile()) ) ) get_sidebar();
?>
</div>
<!-- end:page content -->
<?php
// load footer
get_footer();
?>
I have had the same problem, everything worked fine in any opengraph testing tool and in the social sites themself's: facebook, twitter, ok, vk but in whatsapp & telegram not.
So after a lot of research, the problem was in our virtual site firewall that protects from site crawling by many logics, a couple of them is IP and User-Agent. The whatsapp & telegram are pinging sites to fetch og data are not throw their servers like social sites, but through your mobile operator's dynamic IP, but the user-agent is of the messenger itself, and it was in our automatically generated blacklist.
Check if you don't ban access to your site by theirs user-agents string that contains: WhatsApp/2.17.395 A or TelegramBot (like TwitterBot)
Wish it helped.
Related
I have created a custom page-template with child theme of Official WordPress twenty-seventeen theme.
However i have problem on mobile devices, the pages are not mobile friendly and i get the popup from chrome to make the page mobile friendly and indeed the content is not readable at all on mobile devices.
I am trying make it friendly using W3.css framework, how can i do the content mobile friendly with w3.css or just some css or any other library? Below is the code of the template. Here it is the template-page i use and is not mobile friendly.
<?php
/**
* Template Name: More info template
*
* Description: A custom template for displaying a fullwidth layout with no sidebar.
*
* #package Twenty Seventeen Child
*/
?>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div style="padding:5px;" class="wrap">
<div id="primary" class="content-area">
<main id="main info-template" class="site-main w3-padding" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/page/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
Either create another header and footer specifically for this template so header-new.php and call with:
get_header('new');
or else copy the content of the header.php and footer.php into the top and bottom of your template and remove the html elements that you don't need.
The following tags should NOT be ignored in a template:
<head> <html> wp_head(); and wp_footer();
We have a SaaS product for various clients. Each customer has its own installation in a Virtual Machine. Our user guide has been in Word/PDF. Customer have been able to modify the user guide to add the brand (logo, product name) in the user guide.
Now we want to set up the user guide in Drupal. To move the content of the user guide into Drupal is easy. The challenge is the customization for each customer. We don't want to install Drupal in each Virtual machine and replicate the content.
When someone clicks on "help" in our product they can get to Drupal and we can add parameters for 'client', 'version number' etc. to the URL. Drupal could process this to customize the set up. We can also use the client information for unique login for each client.
I was able to modify the logo by changing $logo in the page template. However, it changes the logo globally for all clients. The latest click to Drupal sets the logo.
I don't know how/where I can set up a logic to customize the logic based on the login. So Client A sees a different logo than client B accessing the same Drupal installation at the same time. In addition we would like to be able to customize the product name in a similar way.
I don't expect any program code (but I would not mind a module). Just some ideas on how to develop this would be great.
This has been the code in the page template. However, the logo changes every time a new client goes to the guide. Is there anything like a session or logoArray[client] feature that I could use to make the logo unique for every client even though many clients access the page concurrently?
<?php
$arglist = drupal_get_query_parameters();
if ( count( $arglist ) > 0 ):
$theme_name = 'bootstrap_ivs7';
$var_name = 'theme_' . $theme_name . '_settings';
$settings = variable_get($var_name, array());
if ( $arglist['logoflag'] == 'logoclient1' ): ?>
<?php if ($logo):
$logo='http://localhost/ivs7/sites/default/files/logo_client1.png';
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php endif;
else:
if ( $arglist['logoflag'] == 'logoclient2' ):
$logo='http://localhost/ivs7/sites/default/files/logo_client2.png';
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php
else:
$logo = 'http://localhost/ivs7/sites/all/images/logo_default.png'; ?>
$settings['logo_path'] = $logo;
variable_set($var_name, $settings);
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php
<a class="logo navbar-btn pull-left" href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
</a>
?>
From a custom module or a theme, you can can implement hook_preprocess_HOOK() to alter the variables of any template. Likely the variables you want to customize per client are all used in the page.tpl.php template, so that would be XYZ_preprocess_page() (where XYZ is the name of your theme or module).
I need wordpress plugin for this kind of header image http://www.slb.com/services/drilling.aspx like in this web site. And this image will not be slider but it's static image on perticular page and category and also different image for all categories and pages.
Easiest & best way is create a custom field named banner & in your header.php place below code.
<div class="banner">
<?php if(get_post_meta($post->ID, 'banner', true)) : ?>
<img src="<?php echo get_post_meta($post->ID, 'banner', true); ?>" />
<?php endif; ?>
<div>
But as you want plugin to do this, have a look at plugin named Dynamic Header.
I have created a custom post-type 'Clients' where admin user can create new clients, add pictures and details to post, then password protect the page so only a particular client can access the content.
For displaying content of this post-type on the front end, I'm using a single-clients.php template. It displays the content perfectly, but the password protect function does not display the form and hide the content, even if I'm in a different browser, cache cleared/logged out of Wordpress (viewing it as a regular end-user would).
What might I be doing wrong here?
<?php get_header(); ?>
<div class="container-client">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Display all fields and content for post-type
<?php endif; ?>
<?php endwhile; else: ?>
<div class="alert-box error">Sorry, this page no longer exists :( — Back to home</div>
<?php endif; ?>
</div>
<?php get_footer(); ?>
This is roughly how my single-clients.php page is setup. Is there any way to manually display the password function so that when end-user visits page, the content is hidden and password form is displayed?
I had exactly this problem and after some trying and reading the codex I came up with this solution:
<?php
add_filter('single_template', function($single_template) {
global $post;
if ($post -> post_type == 'your-custom-post-type') {
if (!post_password_required()) {
$single_template = 'path-to-your/single-your-custom-post-type.php';
}
}
return $single_template;
});
?>
This way the page is only rendered in the custom sinlge view after entering a password, if it is password protected.
We installed Wordpress on our server and the Fishpig extension that integrates Wordpress and Magento. We want to make use of the extension's ability to associate blog posts and products by adding related posts to a new tab on the frontend product page (where the product description and upsell products are). I got all of that to work--there is a new tab on the product pages titled "Related Blog Posts" and when selected, it displays the post titles and excerpts exactly how I wanted it to. The problem is, that tab displays even when there are no related blog posts. How do I hide it when it's empty?
There's probably something simple that I'm missing. Here's how I added the tab:
1) This file app/design/frontend/base/default/layout/wordpress.xml establishes which block the related posts are displayed in on the frontend product page.
In this file, near the bottom, I changed the reference name from product.info.additional to *related_blog_posts*.
2) To the file: app/design/frontend/default/{template}/layout/catalog.xml near line 210, I placed the following code. I put it between similar code portions for the product description and the product upsells.
<action method="addTab" translate="title" module="catalog"><alias>related_blog_posts</alias><title>Related Blog Posts</title><block>catalog/product_list_relatedposts</block><template>catalog/product/list/relatedposts.phtml</template></action>
3) Added a new file: app/code/local/Mage/Catalog/Block/Product/List/relatedposts.php Added the following code to this file:
class Mage_Catalog_Block_Product_List_Relatedposts extends Mage_Core_Block_Template
{
protected $_list;
public function __construct()
{
parent::__construct();
$this->setTemplate('catalog/product/view/additional.phtml');
}
public function getChildHtmlList()
{
if (is_null($this->_list)) {
$this->_list = array();
foreach ($this->getSortedChildren() as $name) {
$block = $this->getLayout()->getBlock($name);
if (!$block) {
Mage::exception(Mage::helper('catalog')->__('Invalid block: %s.', $name));
}
$this->_list[] = $block->toHtml();
}
}
return $this->_list;
}
}
4) Added a new file: app/design/frontend/default/{template}/template/catalog/product/list/Relatedposts.phtml and added the following code to this file:
<?php foreach ($this->getChildHtmlList () as $_html): ?>
<div class="collateral-box">
<?php echo $_html ?>
</div>
<?php endforeach; ?>
5) In the file app/design/frontend/base/default/template/wordpress/post/associated/list.phtml I changed the following code:
<ul>
<?php foreach($posts as $post): ?>
<li>
<?php echo $this->escapeHtml($post->getPostTitle()) ?>
</li>
<?php endforeach; ?>
</ul>
To:
<div class="related-posts">
<?php foreach($posts as $post): ?>
<h3><?php echo $this->escapeHtml($post->getPostTitle()) ?></h3>
<?php $post->setExcerptSize($this->getExcerptLength()) ?>
<p class="related-post-excerpt"><?php echo $post->getPostExcerpt() ?></p>
<?php endforeach; ?>
</div>
This last change adds an excerpt to each related post instead of just displaying the title.
6) Cleared caches and recompiled the site.
Summary: The new tab appears on the frontend product page and the related blog posts are appearing within the tab as they should. The tab, however, displays even when there are no related blog posts for that product. I have tried multiple ways of wrapping the code in Relatedposts.phtml in if/count conditions but I can't get anything to work. How do I prevent my new tab from appearing when there is no content?
I would try something like this or like you had mentioned some sort of count, in
app/design/frontend/default/{template}/template/catalog/product/list/Relatedposts.phtml
<?php
if($this->getChildHtmlList()): ?>
<?php foreach ($this->getChildHtmlList () as $_html): ?>
<div class="collateral-box">
<?php echo $_html ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
You also need to ensure that this block is not returning any white space either because it will be interpreted as content and create the tab. I also had a custom tab and this was the issue for me. If you are having trouble you should Zend_Debug::dump() the $this->getChildHtmlList() and see what is getting generated.