I am trying to setup a custom page, you can take a look here:
http://dageniusmarketer.com/download-the-book-now
and im using this code for my custom page. The sidebars as far as i can tell have IDs of "navigation", and "sidebar", however, the rules i am applying to them are not working. I tried a test rule with the ID "content", and it works as expected. Why am i not able to hide the sidebars? Something isn't making sense.
<?php
/*
* Template Name: My Custom Page
* Description: A Page Template with No Sidebars.
*/
?>
<?php get_header(); ?>
<!--single.php-->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<p class="metadata">
<?php printf(__('%1$s %2$s', 'mtsgossip'), $time_since, get_the_time(__('l, F jS, Y', 'mtsjourney')), get_the_time()); ?>,
<?php _e('by ','mtsjourney');?> <?php the_author();?>
<?php _e('and is filed under','mtsjourney'); ?> "<?php the_category(', ') ?> ".
<?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
// Kommentare und Pingen erlaubt ?>
<?php _e('You can','mtsjourney'); ?> <?php _e('leave a response here','mtsjourney'); ?>,
<?php _e('or send a','mtsjourney'); ?>
<a href="<?php trackback_url(true); ?>" ><?php _e('Trackback','mtsjourney'); ?></a>
<?php _e('from your own site','mtsjourney'); ?>.
<?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
// Nur Pingen erlaubt ?>
<?php _e('Responses are currently closed, but you can send a','mtsjourney'); ?>
<a href="<?php trackback_url(true); ?>" >
<?php _e('Trackback','mtsjourney'); ?></a>
<?php _e('from your own site','mtsjourney'); ?>.
<?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
// Kommentare geschlossen, Pingen erlaubt ?>
<?php _e('You can','mtsjourney'); ?>
<?php _e('leave a response here','mtsjourney'); ?>.
<?php _e('Pinging is currently not allowed','mtsjourney'); ?>.
<?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
// Kommentare und Pings sind nicht erlaubt. ?>
<?php _e('Both comments and pings are currently closed','mtsjourney'); ?>.
<?php } edit_post_link('E','',''); ?>
</p>
</div>
<div id="navigation" style="margin-left:200px;"></div>
<div id="sidebar" style="display:none"></div>
<div id="content" style="width:900px"></div>
<!--postend-->
<p class="navigate">
<?php previous_post_link('« %link') ?>
||
<?php next_post_link(' %link »') ?>
</p>
<?php endwhile; endif;?>
<!--post end-->
<!--single.php end-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Looking at the page structure, I tried to remove left and right sidebar by adding following styles.
Put the following styles as inline css in the desired template, so that it don't affect the layout of any other page. Hope this helps.
div#navigation
{
display:none;
}
div#sidebar
{
display:none;
}
div#content
{
margin: 5px 0 75px 0;
}
Your sidebar is being called with this line:
<?php get_sidebar(); ?>
You can try commenting it out to hide the sidebar:
<?php //get_sidebar(); ?>
You have two divs with the "sidebar" id, the one we can see in the code you posted (Which has the styles) and the one that eventually gets created by <?php get_sidebar(); ?>
These are not the same elements, so to fix your problem just remove that superfluous sidebar and apply the styles in your stylesheet.
Why dont you delete all the content of sidebar.php? so, all other files that call it will show nothing.
your sidebar is being called with this line
<?php get_sidebar(); ?>
try to comment it
Related
I am looking to index my search URLs on Google for SEO ranking. In order for me to do that I need to remove <meta name="robots" content="follow, noindex"/> and replace it with <meta name="robots" content="follow, index"/>
Sample url
https://seosly.com/?s=audit
I am currently using rank math SEO plugin, Tried installing Yoast as well but couldn't find any option there. Given below is my code for search.php file maybe if we can do something from here?
/**
* The template for displaying search results pages.
*/
$mts_options = get_option(MTS_THEME_NAME);
get_header(); ?>
<div id="page">
<div class="article <?php mts_article_class(); ?>">
<div id="content_box">
<h1 class="postsby">
<span><?php _e("Search Results for:", 'myblog' ); ?></span> <?php the_search_query(); ?>
</h1>
<?php $j = 0; if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="latestPost excerpt <?php echo (++$j % 3 == 0) ? 'last' : ''; ?>">
<?php mts_archive_post(); ?>
</article><!--.post excerpt-->
<?php endwhile; else: ?>
<div class="no-results">
<h2><?php _e('We apologize for any inconvenience, please hit back on your browser or use the search form below.', 'myblog' ); ?></h2>
<?php get_search_form(); ?>
</div><!--noResults-->
<?php endif; ?>
<?php if ( $j !== 0 ) { // No pagination if there is no posts ?>
<?php mts_pagination(); ?>
<?php } ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?> ```
I missed that this was specific to the search results page. WordPress adds a default noindex to that page which you should be able to remove with:
remove_filter( 'wp_robots', 'wp_robots_noindex_search' );
I am working with the following codes for Magento inside product page view.phtml.
<div class="manufacturer">
<?php if ($_product->getAttributeText('manufacturer') == "Bellazza" || "Della" || "Pet Zone" || "Spyder Auto" ):?>
<div class="dealer">
<p>Authorized Dealer:</p>
</div>
<div class="logoImg">
<?php echo $this->getLayout()->createBlock('manufacturer/manufacturer')->setProduct($_product)->setTemplate('manufacturer/product_manufacturer.phtml')->toHtml();?>
</div>
<?php elseif ?>
<?php endif;?>
</div>
So I create div.manufacturer to display associated brand logo image started by the title "Authorized Dealer". It works. But not all products have a brand so when I set the manufacturer attribute to empty ( refer to the image below ) I don't need the title "Authorized Dealer" anymore. What is the best practice to approach the elseif. Thank you
manufacturer/manufacturer.phtml
<?php
$maufacturers = Mage::getModel('manufacturer/manufacturer')->getCollection()->addFieldToFilter('status',Array('eq'=>1));
$_columnCount=4;
$i=0;
?>
<div class="manufacturer-list">
<?php foreach($maufacturers as $manufacturer): ?>
<?php if(Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName())): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul>
<?php endif; ?>
<li>
<a href="<?php echo $this->getBaseUrl()."catalogsearch/advanced/result/?manufacturer[]=".$manufacturer->getMenufecturerName() ?>">
<?php echo $this->getLayout()->createBlock('core/template')->setmanufacturerimage($manufacturer->getFilename())->setlegend($manufacturer->getLegend())->setListPageFlag(1)->setTemplate('manufacturer/manufacturer_resize.phtml')->toHtml(); ?>
</a>
<div class="manufacturer-name">
<?php echo Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName()) ?>
</div>
</li>
<?php if ($i%$_columnCount==0 && $i!=count($maufacturers)): ?>
</ul>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
product_manufacturer
<?php
$product=$this->getProduct();
if(Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($product->getData('manufacturer'))):
$manufacturers=Mage::getModel('manufacturer/manufacturer')->getCollection()->addFieldToFilter('menufecturer_name',$product->getData('manufacturer'));
foreach($manufacturers as $manufacturer){
$status=$manufacturer->getStatus();
if($status==1){
?>
<div class="manufacturer-img-box">
<a href="<?php echo $this->getBaseUrl()."catalogsearch/advanced/result/?manufacturer[]=".$manufacturer->getMenufecturerName() ?>">
<?php echo $this->getLayout()->createBlock('core/template')->setmanufacturerimage($manufacturer->getFilename())->setlegend($manufacturer->getLegend())->setTemplate('manufacturer/manufacturer_resize.phtml')->toHtml(); ?>
</a>
</div>
<?php }
}
endif;
?>
You need refactoring the code
<div class="manufacturer">
<div class="logoImg">
<?php echo $this->getLayout()->createBlock('manufacturer/manufacturer')->setProduct($_product)->setTemplate('manufacturer/product_manufacturer.phtml')->toHtml();?>
</div>
</div>
and check variable
<?php if(!is_null($manufacturer->getMenufecturerName())): ?>
<div class="manufacturer-name">
<?php
echo Mage::getModel('eav/entity_attribute_source_table')
->setAttribute(Mage::getModel('eav/entity_attribute')
->load(Mage::getModel('eav/entity_attribute')
->getIdByCode('catalog_product',"manufacturer")))
->getOptionText($manufacturer->getMenufecturerName())
?>
</div>
<?php endif; ?>
And you need refactoring your code. Because I loock much excess code in your template. You need get data in you block and in phtml you need render this data by API blocks. getImageSrc(); getManufactures() and more over methods for get processed information.
I can't seem to get this to work. I have an if statement opening with <?php if (have_posts())...etc.. Then, below that I have a conditional statement determining whether or not the post is in a certain category <?php if (is_category())...etc.. This is the part I can't get right. What am I doing wrong?
<?php get_header();?>
<section id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="article-wrapper">
<article id="post-<?php the_ID(); ?>">
<time datetime="<?php the_time('c'); ?>"><?php the_time('F j, Y'); ?></time>
<?php if (is_category('news')) { ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<p class="read-more">Read more</p>
<?php } ?>
<?php if (is_category('podcasts')) {
$custom = get_post_custom($post->ID);
$buzzsprout_code = $custom["buzzsprout_code"][0];
echo do_shortcode($buzzsprout_code);
echo '<p class="read-emails">View emails and comment on this episode</p>';
} ?>
</article>
</div>
<?php endwhile;endif; ?>
<div id="pagination">
<?php my_paginate_links(); ?>
</div>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
From wordpress docs:
is_category() tests to see if you are displaying a category archive, but you are displaying a single post, so this will always return false
in_category() tests to see if a given post has a category in that specific category and must be used in The Loop, but you are trying to figure out what the category is, before you get to the loop.
The short try in_category() instead.
Today I try to integrate sequence slider and advance custom files plugin in WordPress.
There is a problem I faced. I create a field in advance custom files name "slider_type" . then I create 2 conditional filed. image_slider and video_slider.
Now I want to display it in my WordPress homepage/WordPress themes.
Means, when some one select slider type image from backend, font end work only image function or its display only image. or not its display video.
here is my code what I written:
<ul class="sequence-canvas">
<?php
query_posts('post_type=myslider');
if (have_posts()) : while (have_posts()) : the_post();
?>
<li class="<?php the_field('li_class'); ?>">
<div class="<?php the_field('layout_of_slider'); ?>">
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</div>
<?php if(get_field('slider_type') == "Image") {
<img src=\"<?php (get_field('slider_image'); ?>\">
}
else {
<p><?php (get_field('slider_video'); ?></p>
}
?>
<?php endwhile; endif; wp_reset_query(); ?>
</li>
</ul>
When I run this code, my WordPress themes show blank. What is fault here?
That is not valid PHP, try:
<?php if(get_field('slider_type') == "Image") : ?>
<img src="<?php get_field('slider_image'); ?>">
<?php else: ?>
<p><?php get_field('slider_video'); ?></p>
<?php endif ?>
instead of:
<?php if(get_field('slider_type') == "Image") {
<img src=\"<?php (get_field('slider_image'); ?>\">
}
else {
<p><?php (get_field('slider_video'); ?></p>
}
?>
I downloaded the "like/dislike counter" plugin on wordpress and wish to include a like/dislike button in all comments.
The code for the like and dislike button is:
<?php if(function_exists('like_counter_c')) { like_counter_c("Like"); } ?>
<?php if(function_exists('dislike_counter_c')) {dislike_counter_c("Dislike"); } ?>
I have tried placing it in different parts of comments.php but it either puts it above or below the comments and NOT on all of them as desired.
Does anyone have any idea where I should put it?
Below is the code from my comments.php :
<?php
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?>
<p class="nocomments">This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?>
<!-- You can start editing here. -->
<?php if (have_comments()) { ?>
<div id="commentspost"><a name="commentspost"></a>
<h2 class="title"><?php comment_type_count();?> <?php _e('Comments', 'wpzoom'); ?></h2>
<ol class="normalComments"><?php wp_list_comments('type=all&avatar_size=60');?></ol>
</div><!-- end #commentspost -->
<?php if ('closed' == $post->comment_status) : ?>
<?php endif; ?>
<?php }
else { // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) { ?>
<!-- If comments are open, but there are no comments. -->
<div id="commentspost">
<h2 class="title">0 <?php _e('Comments', 'wpzoom'); ?></h2>
<p><?php _e('You can be the first one to leave a comment', 'wpzoom'); ?>.</p>
</div>
<?php } else { // comments are closed ?>
<!-- If comments are closed. -->
<?php } ?>
<?php } ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond">
<div class="cleaner"> </div>
<div class="cancel-comment-reply"><p><?php cancel_comment_reply_link(); ?></p></div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p><?php _e('You must be', 'wpzoom'); ?> <?php _e('logged in', 'wpzoom'); ?> <?php _e('to post a comment.', 'wpzoom'); ?></p>
<?php else : ?>
<?php comment_form(); ?>
<?php if ( $user_ID ) : ?>
<p><?php _e('Logged in as', 'wpzoom'); ?> <?php echo $user_identity; ?>. <?php _e('Log out', 'wpzoom'); ?> »</p>
<?php endif; ?>
<div class="cleaner"> </div>
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
Unless of course I am wrong about this and it should be included in loop.php ?
Thanks in advance!
The function wp_list_comments() displays all the comments, in order to show de like/dislike button you need to create a custom callback function.
Take a look here.
It's not that simple.
The function wp_list_comments lists all the comments of the post at once, so you can't directly insert your lines to modify each comment.
You have some options:
Pull the comments in some other way that allows you to obtain them individually
Store the comments code somehow and edit it to insert what you want
Check this and this: the wp_list_comments function allows you to specify some callback functions to be applied to each comment. I'm sure you can use them to do what you need :)