I'm working on a wordpress website using this search facility:
http://spruce.it/noise/two-category-dropdown-search-filter-in-wordpress/
All is working OK but in the last few lines I want to include a line to say that if there are no posts in the two categories, e.g. dentists in brighton to show a 'there are no posts' kind of message. My php is very limited and what I've tried doesn't work. I was hoping to add it in before the else statement but this may not be correct. Any pointers much appreciated!
<?php else:
if ($_GET['category'] != -1){
header('Location:'.get_category_link($_GET['category']));
} elseif ($_GET['city'] != -1){
header('Location:'.get_category_link($_GET['city']));
} else{
header('Location: http://www.test.com');
}
endif;?>
ADDITIONAL EDIT: here is the whole page content 14/01/14:
<?php
require_once('../../../wp-blog-header.php');
if (($_GET['category'] != -1) && ($_GET['city'] != -1)):
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(
array(
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => 6,
'category__and' => array(
$_GET['city'],
$_GET['category']
),
)
);
?>
<?php get_header(); ?>
<div id="main">
<div id="content" class="wide">
<?php if (have_posts()) : ?>
<h1><?php echo get_cat_name($_GET['category']) ?>,
<?php echo get_cat_name($_GET['city']) ?></h1>
<?php remove_filter ('the_content1', 'wpautop'); ?>
<h2>These <?php echo get_cat_name($_GET['category']) ?> can help you. They service businesses in <?php echo get_cat_name($_GET['city']) ?><?php if( is_category('exeter') ) echo get_page_content(585);
elseif( is_category('birmingham') ) echo get_page_content(587);
elseif( is_category('') ) echo '.';?>
</h2>
<ul id="search1"><?php while (have_posts()) : the_post(); ? >
<a href="http://www.<?php echo get_post_meta($post->ID, 'URL', true); ?>" title="Go to the URL: www.<?php echo get_post_meta($post->ID, 'URL', true); ?>" target="_blank">
<li id="<?php echo get_post_meta($post->ID, 'AdSize', true); ?>"><h5><?php the_title(); ?></h5>
<?php the_post_thumbnail( $size, $attr ); ?>
<div class="doubler"><?php the_content(''); ?>
<p>Tel: <?php echo get_post_meta($post->ID, 'Telephone', true); ?><br />Website: www.<?php echo get_post_meta($post->ID, 'URL', true); ?></p></div>
</li>
</a>
<?php endwhile; ?></ul>
<?php endif; ?>
<div class="localhelp">
<h1>Find Local Help</h1>
<form method="get" id="sponsorsearchform" action="<?php bloginfo('template_url');? >/findsponsor.php" >
<?php wp_dropdown_categories('show_option_none=Select a Category&hide_empty=1&child_of=14&orderby=name&name=category'); ?>
<?php wp_dropdown_categories('show_option_none=Select a Location&hide_empty=1&child_of=13&orderby=name&name=city'); ?>
<input type="submit" value="Search"/>
</form>
</div>
<hr />
<?php comments_template(); ?>
</div><!--end content-->
</div><!--end main-->
<?php get_footer(); ?>
<?php else:
if ($_GET['category'] != -1){
$currentCat = get_category($_GET['category']);
if ($currentCat->category_count > 0) {
header('Location:'.get_category_link($_GET['category']));
} else {
echo "No result found!";
}
} elseif ($_GET['city'] != -1){
$currentCity = get_category($_GET['city']);
if ($currentCity->category_count > 0) {
header('Location:'.get_category_link($_GET['city']));
} else {
echo "No result found!";
}
} else{
header('Location: http://www.test.com');
}
endif;?>
when there are no posts in either category the findsponsor.php is shown (i.e. the page typed above) .. I want it to say no posts found but it doesn't seem to pick up the echo "No result found!", it's just the page but with no results on.
You can get post count by using category_count attribute through get_category like;
<?php else:
if ($_GET['category'] != -1){
$currentCat = get_category($_GET['category']);
if ($currentCat->category_count > 0) {
header('Location:'.get_category_link($_GET['category']));
} else {
echo "No result found!";
}
} elseif ($_GET['city'] != -1){
$currentCity = get_category($_GET['city']);
if ($currentCity->category_count > 0) {
header('Location:'.get_category_link($_GET['city']));
} else {
echo "No result found!";
}
} else{
header('Location: http://www.test.com');
}
endif;?>
Your code only checks if a category or city ID is found. It does not check if there are any posts in one of those categories. You'd need to add some more code to check for that (count posts in that particular category).
Or if it is enough for you to test if a 'valid' category/city id is found, just alter the line in the else statement (redirect to home) and redirect it to a 'no posts found'-page, or echo a message there, something like that.
What is the best choice actually depends on where and when that code is executed. A little bit more explanation of the request flow is needed here.
Related
In my theme it gets the title of the custom taxonomy here
<div class="<?php echo $filters_id . ' '; echo $filters_width; if($layout == 'constrained_fullwidth') echo ' fullwidth-constrained '; if($span_num != 'elastic-portfolio-item' || $layout == 'constrained_fullwidth') echo 'non-fw'; ?>" data-alignment="<?php echo $filter_alignment; ?>" data-color-scheme="<?php echo strtolower($filter_color); ?>">
<div class="container">
<?php if($filter_alignment != 'center' && $filter_alignment != 'left') { ?> <span id="current-category"><?php echo __('All', NECTAR_THEME_NAME); ?></span> <?php } ?> <
<ul>
<?php if($filter_alignment != 'center' && $filter_alignment != 'left') { ?> <li id="sort-label"><?php echo (!empty($options['portfolio-sortable-text'])) ? $options['portfolio-sortable-text'] : __('Sort Portfolio',NECTAR_THEME_NAME); ?>:</li> <?php } ?>
<li><?php echo __('All', NECTAR_THEME_NAME); ?></li>
<?php wp_list_categories(array('title_li' => '', 'taxonomy' => 'project-type', 'show_option_none' => '', 'walker' => new Walker_Portfolio_Filter())); ?>
</ul>
<div class="clear"></div>
</div>
</div>
however whilst it displays the title great, if I add a description, the plugin also displays this here too
I want to make it only show the title...
I am using Salient Visual Composer plugin and showing the Projects "widget" in my page
The page in questions is http://www.jonnyrossmusic.com/acts-2/ where if you click Acoustic for example it also shows the description
I am assuming the problem lies at <?php echo __('All', NECTAR_THEME_NAME); ?>
Thanks
On a Joomla 3.4 site, articles display a "details" section like this by default :
Details
Written by John Doe
Published: 26 October 2015
What file to change, (and if possible how) to get the following result ?
By John Doe, on November 4, 2015
Edit after #itoctopus answer :
you will need to change the override file. You can do that by changing the
file /templates/your-template/html/com_content/article/default.php
Below is the content of the default.php.
What should be changed to achieve the result above ? I see nothing in this file related to the "details" section.
<?php
/**
* #package Joomla.Site
* #subpackage com_content
*
* #copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Create shortcuts to some parameters.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);
JHtml::_('behavior.caption');
?>
<div class="item-page<?php echo $this->pageclass_sfx; ?>" itemscope itemtype="http://schema.org/Article">
<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? JFactory::getConfig()->get('language') : $this->item->language; ?>" />
<?php if ($this->params->get('show_page_heading')) : ?>
<div class="page-header">
<h1> <?php echo $this->escape($this->params->get('page_heading')); ?> </h1>
</div>
<?php endif;
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && $this->item->paginationrelative)
{
echo $this->item->pagination;
}
?>
<?php // Todo Not that elegant would be nice to group the params ?>
<?php $useDefList = ($params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date')
|| $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') ); ?>
<?php if (!$useDefList && $this->print) : ?>
<div id="pop-print" class="btn hidden-print">
<?php echo JHtml::_('icon.print_screen', $this->item, $params); ?>
</div>
<div class="clearfix"> </div>
<?php endif; ?>
<?php if ($params->get('show_title') || $params->get('show_author')) : ?>
<div class="page-header">
<h2 itemprop="name">
<?php if ($params->get('show_title')) : ?>
<?php echo $this->escape($this->item->title); ?>
<?php endif; ?>
</h2>
<?php if ($this->item->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<?php if (strtotime($this->item->publish_up) > strtotime(JFactory::getDate())) : ?>
<span class="label label-warning"><?php echo JText::_('JNOTPUBLISHEDYET'); ?></span>
<?php endif; ?>
<?php if ((strtotime($this->item->publish_down) < strtotime(JFactory::getDate())) && $this->item->publish_down != JFactory::getDbo()->getNullDate()) : ?>
<span class="label label-warning"><?php echo JText::_('JEXPIRED'); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if (!$this->print) : ?>
<?php if ($canEdit || $params->get('show_print_icon') || $params->get('show_email_icon')) : ?>
<?php echo JLayoutHelper::render('joomla.content.icons', array('params' => $params, 'item' => $this->item, 'print' => false)); ?>
<?php endif; ?>
<?php else : ?>
<?php if ($useDefList) : ?>
<div id="pop-print" class="btn hidden-print">
<?php echo JHtml::_('icon.print_screen', $this->item, $params); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($useDefList && ($info == 0 || $info == 2)) : ?>
<?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
<?php endif; ?>
<?php if ($info == 0 && $params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
<?php if (!$params->get('show_intro')) : echo $this->item->event->afterDisplayTitle; endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '0')) || ($params->get('urls_position') == '0' && empty($urls->urls_position)))
|| (empty($urls->urls_position) && (!$params->get('urls_position')))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php if ($params->get('access-view')):?>
<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_fulltext_caption):
echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>" itemprop="image"/> </div>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
endif;
?>
<?php if (isset ($this->item->toc)) :
echo $this->item->toc;
endif; ?>
<div itemprop="articleBody">
<?php echo $this->item->text; ?>
</div>
<?php if ($useDefList && ($info == 1 || $info == 2)) : ?>
<?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'below')); ?>
<?php if ($params->get('show_tags', 1) && !empty($this->item->tags->itemTags)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && !$this->item->paginationrelative):
echo $this->item->pagination;
?>
<?php endif; ?>
<?php if (isset($urls) && ((!empty($urls->urls_position) && ($urls->urls_position == '1')) || ($params->get('urls_position') == '1'))) : ?>
<?php echo $this->loadTemplate('links'); ?>
<?php endif; ?>
<?php // Optional teaser intro text for guests ?>
<?php elseif ($params->get('show_noauth') == true && $user->get('guest')) : ?>
<?php echo $this->item->introtext; ?>
<?php // Optional link to let them register to see the whole article. ?>
<?php if ($params->get('show_readmore') && $this->item->fulltext != null) : ?>
<?php $menu = JFactory::getApplication()->getMenu(); ?>
<?php $active = $menu->getActive(); ?>
<?php $itemId = $active->id; ?>
<?php $link = new JUri(JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId, false)); ?>
<?php $link->setVar('return', base64_encode(JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language), false))); ?>
<p class="readmore">
<a href="<?php echo $link; ?>" class="register">
<?php $attribs = json_decode($this->item->attribs); ?>
<?php
if ($attribs->alternative_readmore == null) :
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
elseif ($readmore = $this->item->alternative_readmore) :
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) :
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif;
elseif ($params->get('show_readmore_title', 0) == 0) :
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
else :
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif; ?>
</a>
</p>
<?php endif; ?>
<?php endif; ?>
<?php
if (!empty($this->item->pagination) && $this->item->pagination && $this->item->paginationposition && $this->item->paginationrelative) :
echo $this->item->pagination;
?>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</div>
You can do the above by CSS - but sometimes it's a bit tricky, so you will need to change the override file. You can do that by changing the file /templates/your-template/html/com_content/article/default.php
If you can't find that file (or that directory structure), then you will need to copy the this file components/com_content/views/article/tmpl/default.php to /templates/your-template/html/com_content/article/default.php (if there is a directory that doesn't exist then you will need to create it. for example, if you can only find the /templates/your-template/html under your templates folder the you will need to create the com_content folder under the html folder and then the article folder under the com_content folder).
You can then modify the default.php file to change the layout. Make sure you clear your Joomla cache to see your changes.
Using CSS and Language overrides worked out.
CSS : display:none to get rid of unwanted stuff and display:inline-block to put everything in a single line.
Changing Words in Joomla 3.4 backend :
from the control panel, click on Languages in the sidebar menu
Click 'overrides'
Choose the language in 'filter'
Click 'new'
in the form field next to 'search' button, type in the text you want to change
select the right string variable
Type in the wanted text
Save
done.
I have a Jomi installation and I see that social icons are inserted at the bottom of my article while I would display them after the head section. What should I look for to modify this since the template settings just allow me to turn on/off the social bar? Should I look inside layouts or styles folder?
On feeling I looked into layouts/com_content/article and there is a default.php that looks something like a template for my articles, but I cannot find anything about social bar, here is its content:
<?php
/**
* #package Warp Theme Framework
* #author YOOtheme http://www.yootheme.com
* #copyright Copyright (C) YOOtheme GmbH
* #license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die;
// get view
$menu = JSite::getMenu()->getActive();
$view = is_object($menu) && isset($menu->query['view']) ? $menu->query['view'] : null;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
// Create shortcuts to some parameters.
$params = $this->item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $this->item->params->get('access-edit');
$user = JFactory::getUser();
?>
<div id="system">
<?php if ($this->params->get('show_page_heading', 1)) : ?>
<h1 class="title"><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php endif; ?>
<article class="item"<?php if ($view != 'article') printf(' data-permalink="%s"', JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catslug), true, -1)); ?>>
<?php if ($params->get('show_title')) : ?>
<header>
<?php if (!$this->print) : ?>
<?php if ($params->get('show_email_icon')) : ?>
<div class="icon email"><?php echo JHtml::_('icon.email', $this->item, $params); ?></div>
<?php endif; ?>
<?php if ($params->get('show_print_icon')) : ?>
<div class="icon print"><?php echo JHtml::_('icon.print_popup', $this->item, $params); ?></div>
<?php endif; ?>
<?php else : ?>
<div class="icon printscreen"><?php echo JHtml::_('icon.print_screen', $this->item, $params); ?></div>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<header class="clearfix">
<time datetime="<?php echo substr($this->item->created, 0,10); ?>" pubdate>
<span class="day"><?php echo JHTML::_('date',$this->item->created, JText::_('d')); ?></span>
<span class="month"><?php echo JHTML::_('date',$this->item->created, JText::_('M')); ?></span>
<span class="year"><?php echo JHTML::_('date',$this->item->created, JText::_('Y')); ?></span>
</time>
<?php endif; ?>
<h1 class="title"><?php echo $this->escape($this->item->title); ?></h1>
<?php if (($params->get('show_author') && !empty($this->item->author)) || $params->get('show_category')) : ?>
<p class="meta">
<?php
if ($params->get('show_author') && !empty($this->item->author )) {
$author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author;
if (!empty($this->item->contactid) && $params->get('link_author') == true) {
$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
$menu = JFactory::getApplication()->getMenu();
$item = $menu->getItems('link', $needle, true);
$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
echo JText::sprintf('<i class="icon-user"></i>');
echo JText::sprintf('COM_CONTENT_WRITTEN_BY', JHtml::_('link', JRoute::_($cntlink), $author));
} else {
echo JText::sprintf('<i class="icon-user"></i>');
echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author);
}
}
if ($params->get('show_author') && !empty($this->item->author )) {
echo '. ';
}
if ($params->get('show_category')) {
echo JText::_('<i class="icon-folder-open-alt"></i>').' ';
echo JText::_('TPL_WARP_POSTED_IN').' ';
$title = $this->escape($this->item->category_title);
$url = ''.$title.'';
if ($params->get('link_category') AND $this->item->catslug) {
echo $url;
} else {
echo $title;
}
}
?>
</p>
<?php endif; ?>
</header>
<?php endif; ?>
<?php
if (!$params->get('show_intro')) {
echo $this->item->event->afterDisplayTitle;
}
echo $this->item->event->beforeDisplayContent;
if (isset ($this->item->toc)) {
echo $this->item->toc;
}
?>
<div class="content clearfix">
<?php
if ($params->get('access-view')) {
if (isset($urls) AND ((!empty($urls->urls_position) AND ($urls->urls_position=='0')) OR ($params->get('urls_position')=='0' AND empty($urls->urls_position) ))
OR (empty($urls->urls_position) AND (!$params->get('urls_position')))) {
echo $this->loadTemplate('links');
}
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) {
$imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext;
$class = (htmlspecialchars($imgfloat) != 'none') ? ' class="size-auto align-'.htmlspecialchars($imgfloat).'"' : ' class="size-auto"';
$title = ($images->image_fulltext_caption) ? ' title="'.htmlspecialchars($images->image_fulltext_caption).'"' : '';
echo '<img'.$class.$title.' src="'.htmlspecialchars($images->image_fulltext).'" alt="'.htmlspecialchars($images->image_fulltext_alt).'" />';
}
echo $this->item->text;
if (isset($urls) AND ((!empty($urls->urls_position) AND ($urls->urls_position=='1')) OR ( $params->get('urls_position')=='1') )) {
echo $this->loadTemplate('links');
}
// optional teaser intro text for guests
} elseif ($params->get('show_noauth') == true AND $user->get('guest')) {
echo $this->item->introtext;
// optional link to let them register to see the whole article.
if ($params->get('show_readmore') && $this->item->fulltext != null) {
$link1 = JRoute::_('index.php?option=com_users&view=login');
$link = new JURI($link1);
echo '<p class="links">';
echo '<a href="'.$link.'">';
$attribs = json_decode($this->item->attribs);
if ($attribs->alternative_readmore == null) {
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
} elseif ($readmore = $this->item->alternative_readmore) {
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) {
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
}
} elseif ($params->get('show_readmore_title', 0) == 0) {
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
} else {
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
}
echo '</a></p>';
}
}
?>
</div>
<?php if ($canEdit) : ?>
<p class="edit"><?php echo JHtml::_('icon.edit', $this->item, $params); ?> <?php echo JText::_('TPL_WARP_EDIT_ARTICLE'); ?></p>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?>
</article>
</div>
The only point that could reasonable be the social bar is this line:
<?php echo $this->item->event->afterDisplayContent; ?>
However it looks like a ore wider concept, since afterDisplayContent probably handles many things, and here is where I stop, I have no idea where to look for afterDisplayContent event definition, I guess that I should find an entry for social bar and copy/paste in the position that I want in my module.
We are using Elision WP theme. We have a revolution slider on home pulled via shortcode in theme backend settings. We need to have static text on top of slides.
Revolution slider is set to 1100px x 680px and we want the "hero-text" div to be located on the lower left corner with a 20px from left and 50px from bottom. It also needs to be responsive.
Attached: layout image link, homepage.php code.
http://www.image-share.com/ijpg-2756-164.html
<?php
/*
Template Name: Homepage
*/
?>
<?php
global $wp_query;
$id = $wp_query->get_queried_object_id();
$sidebar = get_post_meta($id, "qode_show-sidebar", true);
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }
if(get_post_meta($id, "qode_responsive-title-image", true) != ""){
$responsive_title_image = get_post_meta($id, "qode_responsive-title-image", true);
}else{
$responsive_title_image = $qode_options_elision['responsive_title_image'];
}
if(get_post_meta($id, "qode_fixed-title-image", true) != ""){
$fixed_title_image = get_post_meta($id, "qode_fixed-title-image", true);
}else{
$fixed_title_image = $qode_options_elision['fixed_title_image'];
}
if(get_post_meta($id, "qode_title-image", true) != ""){
$title_image = get_post_meta($id, "qode_title-image", true);
}else{
$title_image = $qode_options_elision['title_image'];
}
$title_image_height = "";
$title_image_width = "";
if(!empty($title_image)){
$title_image_url_obj = parse_url($title_image);
if (file_exists($_SERVER['DOCUMENT_ROOT'].$title_image_url_obj['path']))
list($title_image_width, $title_image_height, $title_image_type, $title_image_attr) = getimagesize($_SERVER['DOCUMENT_ROOT'].$title_image_url_obj['path']);
}
if(get_post_meta($id, "qode_title-height", true) != ""){
$title_height = get_post_meta($id, "qode_title-height", true);
}else{
$title_height = $qode_options_elision['title_height'];
}
$title_background_color = '';
if(get_post_meta($id, "qode_page-title-background-color", true) != ""){
$title_background_color = get_post_meta($id, "qode_page-title-background-color", true);
}else{
$title_background_color = $qode_options_elision['title_background_color'];
}
$show_title_image = true;
if(get_post_meta($id, "qode_show-page-title-image", true)) {
$show_title_image = false;
}
$qode_page_title_style = "standard";
if(get_post_meta($id, "qode_page_title_style", true) != ""){
$qode_page_title_style = get_post_meta($id, "qode_page_title_style", true);
}else{
if(isset($qode_options_elision['title_style'])) {
$qode_page_title_style = $qode_options_elision['title_style'];
} else {
$qode_page_title_style = "standard";
}
}
$height_class = "";
if($qode_page_title_style == "title_on_bottom") {
$height_class = " title_on_bottom";
}
$enable_page_comments = false;
if(get_post_meta($id, "qode_enable-page-comments", true)) {
$enable_page_comments = true;
}
?>
<?php get_header(); ?>
<?php if(get_post_meta($id, "qode_page_scroll_amount_for_sticky", true)) { ?>
<script>
var page_scroll_amount_for_sticky = <?php echo get_post_meta($id, "qode_page_scroll_amount_for_sticky", true); ?>;
</script>
<?php } ?>
<?php if(!get_post_meta($id, "qode_show-page-title", true)) { ?>
<div class="title<?php echo $height_class; ?> <?php if($responsive_title_image == 'no' && $title_image != "" && ($fixed_title_image == "yes" || $fixed_title_image == "yes_zoom") && $show_title_image == true){ echo 'has_fixed_background '; if($fixed_title_image == "yes_zoom"){ echo 'zoom_out '; } } if($responsive_title_image == 'no' && $title_image != "" && $fixed_title_image == "no" && $show_title_image == true){ echo 'has_background'; } if($responsive_title_image == 'yes' && $show_title_image == true){ echo 'with_image'; } ?>" style="<?php if($responsive_title_image == 'no' && $title_image != "" && $show_title_image == true){ if($title_image_width != ''){ echo 'background-size:'.$title_image_width.'px auto;'; } echo 'background-image:url('.$title_image.');'; } if($title_height != ''){ echo 'height:'.$title_height.'px;'; } if($title_background_color != ''){ echo 'background-color:'.$title_background_color.';'; } ?>">
<div class="image <?php if($responsive_title_image == 'yes' && $title_image != "" && $show_title_image == true){ echo "responive"; }else{ echo "not_responsive"; } ?>"><?php if($title_image != ""){ ?><img src="<?php echo $title_image; ?>" alt=" " /> <?php } ?></div>
<?php if(!get_post_meta($id, "qode_show-page-title-text", true)) { ?>
<div class="title_holder">
<div class="container">
<div class="container_inner clearfix">
<?php if($qode_page_title_style == "title_on_bottom") { ?>
<div class="title_on_bottom_wrap">
<div class="title_on_bottom_holder">
<div class="title_on_bottom_holder_inner" <?php if(get_post_meta($id, "qode_page_title_holder_color", true)) { ?> style="background-color:<?php echo get_post_meta($id, "qode_page_title_holder_color", true) ?>" <?php } ?>>
<h1<?php if(get_post_meta($id, "qode_page-title-color", true)) { ?> style="color:<?php echo get_post_meta($id, "qode_page-title-color", true) ?>" <?php } ?>><span><?php the_title(); ?></span></h1>
</div>
</div>
</div>
<?php } else { ?>
<h1<?php if(get_post_meta($id, "qode_page-title-color", true)) { ?> style="color:<?php echo get_post_meta($id, "qode_page-title-color", true) ?>" <?php } ?>><span><?php the_title(); ?></span></h1>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
<?php
$revslider = get_post_meta($id, "qode_revolution-slider", true);
if (!empty($revslider)){ ?>
<div class="q_slider"><div class="q_slider_inner">
<?php echo do_shortcode($revslider); ?>
</div></div>
<?php
}
?>
<div class="full_width">
<div class="full_width_inner">
<?php if(($sidebar == "default")||($sidebar == "")) : ?>
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php
$args_pages = array(
'before' => '<p class="single_links_pages">',
'after' => '</p>',
'pagelink' => '<span>%</span>'
);
wp_link_pages($args_pages); ?>
<?php
if($enable_page_comments){
?>
<div class="container">
<div class="container_inner">
<?php
comments_template('', true);
?>
</div>
</div>
<?php
}
?>
<?php endwhile; ?>
<?php endif; ?>
<?php elseif($sidebar == "1" || $sidebar == "2"): ?>
<?php if($sidebar == "1") : ?>
<div class="two_columns_66_33 clearfix grid2">
<div class="column1">
<?php elseif($sidebar == "2") : ?>
<div class="two_columns_75_25 clearfix grid2">
<div class="column1">
<?php endif; ?>
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="column_inner">
<?php the_content(); ?>
<?php
$args_pages = array(
'before' => '<p class="single_links_pages">',
'after' => '</p>',
'pagelink' => '<span>%</span>'
);
wp_link_pages($args_pages); ?>
<?php
if($enable_page_comments){
?>
<div class="container">
<div class="container_inner">
<?php
comments_template('', true);
?>
</div>
</div>
<?php
}
?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<div class="column2"><?php get_sidebar();?></div>
</div>
<?php elseif($sidebar == "3" || $sidebar == "4"): ?>
<?php if($sidebar == "3") : ?>
<div class="two_columns_33_66 clearfix grid2">
<div class="column1"><?php get_sidebar();?></div>
<div class="column2">
<?php elseif($sidebar == "4") : ?>
<div class="two_columns_25_75 clearfix grid2">
<div class="column1"><?php get_sidebar();?></div>
<div class="column2">
<?php endif; ?>
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="column_inner">
<?php the_content(); ?>
<?php
$args_pages = array(
'before' => '<p class="single_links_pages">',
'after' => '</p>',
'pagelink' => '<span>%</span>'
);
wp_link_pages($args_pages); ?>
<?php
if($enable_page_comments){
?>
<div class="container">
<div class="container_inner">
<?php
comments_template('', true);
?>
</div>
</div>
<?php
}
?>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
I'm not sure how you're planning to get your static headline onto the page. You could hard code it in there as I am about to show you below or you could create a custom field. If you decide to take that route, I find that Advanced Custom Fields is really easy to use.
<?php
$revslider = get_post_meta($id, "qode_revolution-slider", true);
if (!empty($revslider)){ ?>
<div class="q_slider"><div class="q_slider_inner">
<h1 class="static-headline">Your awesome text goes here</h1>
<?php echo do_shortcode($revslider); ?>
</div></div>
<?php
Add the following CSS to your site to position it in the correct place:
.q_slider_inner { position: relative; }
.static-headline {
position: absolute;
bottom: 5%;
left: 2%;
color: #fff;
z-index: 21;
}
You'll need to play around with the percentages to get the headline exactly where you need it but I recommend using % over px values since you want this to be responsive.
I hope this helps.
UPDATE:
Thanks to everybody's wonderful input, I now have the code working properly in the main page. Still can't figure out why that same code isn't functioning in the widget. it's pulling down the title and permalink, so I know it's getting the data, but the custom values are returning as zero
I am making a wordpress page in which the group using the page is accepting challenges from viewers.
The challenges page is a special template that shows a percentage bar of how complete the challenge is.
the bar was working OK, with a small glitch in chrome, but the client wanted 'pending' for challenges that had 0% completeion and 'completed' for 100% instead of the graph.
I've put this code into both the page and a widget with strange results. on the page, only the percentage bar ever shows, but on the widget, all challenges are listed as 'pending'
my code for the page is as follows:
<?php
/**
* Template Name: Challenges Page
*/
?>
<?php get_header(); ?>
<!-- content -->
<div id="content">
<?php query_posts( array( 'post_type' => 'challenges', 'posts_per_page' => -1 ) ); ?>
<?php while (have_posts()) : the_post(); $more = 0; ?>
<div class="post archive">
<div class="post-comments"><?php comments_popup_link('0', '1', '%'); ?></div>
<h3><?php the_title(); ?></h3>
<?php
$target = get_post_meta($post->ID, 'target', true);
$complete = get_post_meta($post->ID, 'complete', true);
$percentage = $complete / $target;
$percentage = round($percentage * 100);
$whatsleft = 100-$percentage;
if($whatsleft < 0) $whatsleft=0;
echo "<table width='250' border='0' cellpadding='0' cellspacing='0'><tr>";
if($complete == $target) {
echo "<td><img src='http://www.smokeyvstheworld.com/wp-content/uploads/2012/05/completed.gif' style='width:200>px;height:24px;'></td>";
} else if ($complete == 0) {
echo "<td><img src='http://www.smokeyvstheworld.com/wp-content/uploads/2012/05/pending.gif' style='width:200>px;height:24px;'></td>";
} else {
echo "<td><img src='http://www.smokeyvstheworld.com/wp-content/themes/spectre/images/brown/grnbar.jpg' style='width:". $percentage ."px;height:12px;'></td><td><img src='http://www.smokeyvstheworld.com/wp-content/themes/spectre/images/brown/grybar.jpg' style='width:". $whatsleft ."px;height:12px;'></td>";
}
echo "</tr><tr><td colspan='2'><div align='right'>". $complete ." of ". $target ." completed</div></td></tr></table>";
?>
<div class="post-date"><?php the_time('l, F jS, Y') ?></div>
<?php if (get_post_meta($post->ID, 'post_image_value', true)) { ?><div class="post-tnail"><?php if (get_post_meta($post->ID, 'post_image_value', true) && $mb_resize == 0) { ?><img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "post_image_value", $single = true); ?>&w=98&h=98&zc=1&q=95" alt="<?php the_title(); ?>" /><?php } else if (get_post_meta($post->ID, 'post_image_value', true) && $mb_resize == 1) { ?><img src="<?php bloginfo('home'); ?><?php echo get_post_meta($post->ID, "post_image_value", $single = true); ?>" alt="<?php the_title(); ?>" /><?php } ?></div><?php } ?>
<?php the_excerpt() ?>
<p>Continue reading...</p>
</div>
<?php endwhile; ?>
</div>
<div id="sidebar"><?php get_sidebar(); ?></div>
<?php get_footer(); ?>
I'm confused as to WHAT I'm doing wrong, and why the same code works in one instance and not the other... I've tried switching from brackets to colons and back, etc.
width:200>px;height:24px; => width:200px;height:24px;
Try
$target = (int) get_post_meta($post->ID, 'target', true);
$complete = (int) get_post_meta($post->ID, 'complete', true);
Try changing both the == to === so:
if($complete === $target) {
and
} else if ($complete === 0) {
Edit:
Thinking about it, the $complete value is probably a string so if above doesn't work change that line to
} else if ($complete === "0") {