Because I'm using a couple of custom post types and two languages I decided not to use WP's own menu function, and used these conditional statements instead -
<div class="navigation">
<ul>
<li><a <?php if(is_page('home') || is_page('hem')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo(url) . '">Home'; } else { echo 'href="' . get_bloginfo(url) . '">Hem'; } ?></a></li>
<li><a <?php if(is_page('offers') || is_page('erbjudanden') || in_category('offers') || in_category('erbjudanden')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'offers">Offers'; } else { echo 'href="' . get_bloginfo('url') . '/erbjudanden">Erbjudanden'; } ?></a></li>
<li><a <?php if(is_page('properties-spain') || is_page('fastigheter-spanien')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'properties-spain">Properties in Spain'; } else { echo 'href="' . get_bloginfo('url') . '/fastigheter-spanien">Fastigheter i Spanien'; } ?></a></li>
<li><a <?php if(is_page('properties-usa') || is_page('fastigheter-usa')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'properties-usa">Properties in USA'; } else { echo 'href="' . get_bloginfo('url') . '/fastigheter-usa">Fastigheter i USA'; } ?></a></li>
<li><a <?php if(is_subpage('information') || is_subpage('radgivning')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'information/process-of-purchase">Information'; } else { echo 'href="' . get_bloginfo('url') . '/radgivning/hur-ett-kop-gar-till">Rådgivning'; } ?></a></li>
<li><a <?php if(is_page('about-us') || is_page('om-oss')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'about-us">About us'; } else { echo 'href="' . get_bloginfo('url') . '/om-oss">Om oss'; } ?></a></li>
<li class="last"><a <?php if(is_page('contact') || is_page('kontakt')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'contact">Contact'; } else { echo 'href="' . get_bloginfo('url') . '/kontakt">Kontakt'; } ?></a></li>
</ul>
</div>
Now this works excellent including it in the header file but in the footer file only some of the links are given a class of active when on the actual page. All the items in the menu exists as pages, with one version for each language (swedish and english). This error just seems really weird and I've tried checking with different conditional parameters such as page title, page id etc. with no results. Any ideas?
Sometimes queries higher up in the template source will corrupt the output of conditional tags lower down (i.e. in your footer). The trick is to put wp_reset_query() before you use them in your footer include:
<?php wp_reset_query(); ?>
<div class="navigation">
<ul>
<li><a <?php if(is_page('home') || is_page('hem')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo(url) . '">Home'; } else { echo 'href="' . get_bloginfo(url) . '">Hem'; } ?></a></li>
<li><a <?php if(is_page('offers') || is_page('erbjudanden') || in_category('offers') || in_category('erbjudanden')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'offers">Offers'; } else { echo 'href="' . get_bloginfo('url') . '/erbjudanden">Erbjudanden'; } ?></a></li>
<li><a <?php if(is_page('properties-spain') || is_page('fastigheter-spanien')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'properties-spain">Properties in Spain'; } else { echo 'href="' . get_bloginfo('url') . '/fastigheter-spanien">Fastigheter i Spanien'; } ?></a></li>
<li><a <?php if(is_page('properties-usa') || is_page('fastigheter-usa')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'properties-usa">Properties in USA'; } else { echo 'href="' . get_bloginfo('url') . '/fastigheter-usa">Fastigheter i USA'; } ?></a></li>
<li><a <?php if(is_subpage('information') || is_subpage('radgivning')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'information/process-of-purchase">Information'; } else { echo 'href="' . get_bloginfo('url') . '/radgivning/hur-ett-kop-gar-till">Rådgivning'; } ?></a></li>
<li><a <?php if(is_page('about-us') || is_page('om-oss')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'about-us">About us'; } else { echo 'href="' . get_bloginfo('url') . '/om-oss">Om oss'; } ?></a></li>
<li class="last"><a <?php if(is_page('contact') || is_page('kontakt')) { echo 'class="active" '; } if (ICL_LANGUAGE_CODE == 'en') { echo 'href="' . get_bloginfo('url') . 'contact">Contact'; } else { echo 'href="' . get_bloginfo('url') . '/kontakt">Kontakt'; } ?></a></li>
</ul>
</div>
Related
I've been trying to add repeater fields in my wordpress widget form. I found two plugin examples but they don't work anymore. When I click on "Add row", nothing happens.
https://www.commoninja.com/discover/wordpress/plugin/social-repeater-widget
https://www.zealousweb.com/wordpress-plugins/repeater-entries-widget/
I noticed both use jquery in their widgets which I guess doesn't work anymore in the newer Wordpress versions?
/**
* Back-end widget form.
*
* #see WP_Widget::form()
*
* #param array $instance Previously saved values from database.
*/
public function form($instance)
{
$max_entries = get_option( 'max_entries' );
$max_entries = (empty($max_entries)) ? '5' : $max_entries;
$widget_add_id = $this->id . "-add";
$title = !empty($instance['title']) ? $instance['title'] : __('Social Repeater Widget', 'srw-widget');
$srw_html = '<p>';
$srw_html .= '<label for="'.$this->get_field_id('title').'"> '. __( 'Widget Title', 'srw-widget' ) .' :</label>';
$srw_html .= '<input id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" type="text" value="'.$title.'" />';
$srw_html .= '<div class="'.$widget_add_id.'-input-containers"><div id="entries">';
for( $i =0; $i<$max_entries; $i++){
if(isset($instance['block-' . $i]) || isset($instance['social_platform-' . $i]))
{
$srw_tab_title = !empty($instance['social_platform-' . $i]) ? $instance['social_platform-' . $i] : __( 'Add Social Profile Details', 'srw-widget' );
$display = (!isset($instance['block-' . $i]) || ($instance['block-' . $i] == "")) ? 'style="display:none;"' : '';
$srw_html .= '<div id="entry'.($i+1).'" '.$display.' class="entrys"><span class="entry-title" onclick = "slider(this);"> '.$srw_tab_title.' </span>';
$srw_html .= '<div class="entry-desc cf">';
$srw_html .= '<input id="'.$this->get_field_id('block-' . $i ).'" name="'.$this->get_field_name('block-' . $i ).'" type="hidden" value="'.$instance['block-' . $i].'">';
$social_platform = esc_attr( $instance['social_platform-' . $i] );
$social_platform_link = esc_attr( $instance['social_platform_link-' . $i] );
$srw_html .= '<p class="last desc">';
$srw_html .= '<label for="'.$this->get_field_id('social_platform-' . $i).'"> '. __( 'Social Platform', 'srw-widget' ) .' :</label>';
$srw_html .= '<input class="widefat" id="'.$this->get_field_id('social_platform-' . $i).'" name="'.$this->get_field_name('social_platform-' . $i).'" type="text" value="'.$social_platform.'" placeholder="'.__( 'Enter Social Platform name', 'srw-widget' ).'" />';
$srw_html .= '</p><p>';
$srw_html .= '<label for="'.$this->get_field_id('social_platform_link-' . $i).'"> '. __('Social platform Link', 'srw-widget' ) .' :</label>';
$srw_html .= '<input class="widefat" id="'.$this->get_field_id('social_platform_link-' . $i).'" name="'.$this->get_field_name('social_platform_link-' . $i).'" type="url" value="'.$social_platform_link.'" placeholder="'.__( 'Enter Social Platform Link', 'srw-widget' ).'"/>';
$srw_html .= '</p>';
/* end wrapper with delete entry option */
$srw_html .= '<p><span class="delete-row">'. __( 'Delete Row', 'srw-widget' ) .'</span></p>';
$srw_html .= '</div></div>';
}
}
$srw_html .= '</div></div>';
$srw_html .= '<div id="message">'. __( 'Sorry, you reached to the limit of','srw-widget') .' "'.$max_entries.'" '. __( 'maximum entries', 'srw-widget' ) .'.</div>' ;
$srw_html .= '<div class="'.$widget_add_id.'" style="display:none;">' . __('Add New Platform', 'srw-widget') . '</div>';
?>
<script>
jQuery(document).ready(function(e) {
jQuery.each(jQuery(".<?php echo $widget_add_id; ?>-input-containers #entries").children(), function(){
if(jQuery(this).find('input').val() != ''){
jQuery(this).show();
}
});
jQuery(".<?php echo $widget_add_id; ?>" ).bind('click', function(e) {
var rows = 0;
jQuery.each(jQuery(".<?php echo $widget_add_id; ?>-input-containers #entries").children(), function(){
if(jQuery(this).find('input').val() == ''){
jQuery(this).find(".entry-title").addClass("active");
jQuery(this).find(".entry-desc").slideDown();
jQuery(this).find('input').first().val('0');
jQuery(this).show();
return false;
}
else{
rows++;
jQuery(this).show();
jQuery(this).find(".entry-title").removeClass("active");
jQuery(this).find(".entry-desc").slideUp();
}
});
if(rows == '<?php echo $max_entries;?>')
{
jQuery("#rew_container #message").show();
}
});
jQuery(".delete-row" ).bind('click', function(e) {
var count = 1;
var current = jQuery(this).closest('.entrys').attr('id');
jQuery.each(jQuery("#entries #"+current+" .entry-desc").children(), function(){
jQuery(this).val('');
});
jQuery.each(jQuery("#entries #"+current+" .entry-desc p").children(), function(){
jQuery(this).val('');
});
jQuery('#entries #'+current+" .entry-title").removeClass('active');
jQuery('#entries #'+current+" .entry-desc").hide();
jQuery('#entries #'+current).remove();
jQuery.each(jQuery(".<?php echo $widget_add_id; ?>-input-containers #entries").children(), function(){
if(jQuery(this).find('input').val() != ''){
jQuery(this).find('input').first().val(count);
}
count++;
});
});
});
</script>
<style>
.cf:before, .cf:after { content: ""; display: table; }
.cf:after { clear: both; }
.cf { zoom: 1; }
.clear { clear: both; }
.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix { display: inline-block; }
* html .clearfix { height: 1%; }
.clearfix { display: block;}
#rew_container input,select,textarea{ float: right;width: 60%;}
#rew_container label{width:40%;}
<?php echo '.'.$widget_add_id; ?>{
background: #ccc none repeat scroll 0 0;font-weight: bold;margin: 20px 0px 9px;padding: 6px;text-align: center;display:block !important; cursor:pointer;
}
.desc{height:55px;}
#entries{ padding:10px 0 0;}
#entries .entrys{ padding:0; border:1px solid #e5e5e5; margin:10px 0 0; clear:both;}
#entries .entrys:first-child{ margin:0;}
#entries .delete-row{margin-top:20px;float:right;text-decoration: underline;color:red;}
#entries .entry-title{ display:block; font-size:14px; line-height:18px; font-weight:600; background:#f1f1f1; padding:7px 5px; position:relative;}
#entries .entry-title:after{ content: '\f140'; font: 400 20px/1 dashicons; position:absolute; right:10px; top:6px; color:#a0a5aa;}
#entries .entry-title.active:after{ content: '\f142';}
#entries .entry-desc{ display:none; padding:0 10px 10px; border-top:1px solid #e5e5e5;}
#rew_container #entries p.last label{ white-space: pre-line; float:left; width:39%;}
#message{padding:6px;display:none;color:red;font-weight:bold;}
</style>
<div id="rew_container">
<?php echo $srw_html;?>
</div>
<?php
}
I'm pretty new to php and wordpress so any help would be appreciated.
Please try the below code to create a repeater field in the widget.
dd_action( 'widgets_init', 'services_widget' );
function services_widget() {
register_widget( 'services_widget' );
}
class services_widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'services_widget',
'description' => 'Add a service description.'
);
$control_ops = array( 'width' => 400, 'height' => 350 );
parent::__construct( 'services_widget', 'Services', $widget_ops, $control_ops );
}
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
}
if( have_rows('service', 'widget_' . $args['widget_id']) ):
echo '<ul>';
while ( have_rows('service', 'widget_' . $args['widget_id']) ) : the_row();
echo '<li class="service one-half">';
$title = get_sub_field( 'title', 'widget_' . $args['widget_id'] );
$body = get_sub_field( 'body', 'widget_' . $args['widget_id']);
$button = get_sub_field( 'button', 'widget_' . $args['widget_id'] );
$button_link = get_sub_field( 'button_link', 'widget_' . $args['widget_id'] );
if( $title ) {
echo '<h4>' . $title . '</h4>';
}
if( $body ) {
echo '<p>' . $body . '</p>';
}
if( $body ) {
echo '<a class="more" href="' . $button_link . '">' .$button . '</a>';
}
echo '</li><div class="clearfix"></div></ul>';
endwhile;
endif;
echo $args['after_widget'];
}
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
$filter = isset( $instance['filter'] ) ? $instance['filter'] : 0;
$title = sanitize_text_field( $instance['title'] );
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox"<?php checked( $filter ); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = sanitize_text_field( $new_instance['title'] );
if ( current_user_can( 'unfiltered_html' ) ) {
$instance['text'] = $new_instance['text'];
} else {
$instance['text'] = wp_kses_post( $new_instance['text'] );
}
$instance['filter'] = ! empty( $new_instance['filter'] );
return $instance;
}
}
If trying to get Wordpress to pull through a list of child titles based on the parent but all its pulls through is just one or two titles. Any suggestions?
Code below
function get_categories_list() {
$parent = $child = array();
foreach (get_the_category(get_the_id()) as $cat) {
if ($cat->id === 0) {
continue;
}
if ($cat->category_parent === 0) {
array_push($parent,$cat);
} else {
array_push($child,$cat);
}
}
foreach ($parent as $key => $cat) {
if ($key !== 0) {
echo "-";
}
echo ' ' . $cat->name . '';
}
foreach ($child as $cat) {
if ($key !== 0) {
echo "-";
}
echo ' ' . $cat->name . '';
}
}
foreach ($child as $cat) {
if ($key !== 0) {
echo "-";
}
echo ' ' . $cat->name . '';
}
Should be
foreach ($child as $key => $cat) {
if ($key !== 0) {
echo "-";
}
echo ' ' . $cat->name . '';
}
I have problem displaying my wp_list_categories with Style. I am already using args, etc but that does not seem to help with the problem.
I want to display same sub-categories for single article.
Here my code :
<?php
if (is_home()) {
wp_list_categories('orderby=id&title_li=none&depth=1');
} else {
$category = get_the_category();
$cat_term_id = $category[0]->term_id;
$cat_category_parent = $category[0]->category_parent;
$listcat = wp_list_categories('echo=0&child_of='.$cat_category_parent.'&title_li=');
$listcat = str_replace("cat-item-".$cat_term_id, "cat-item-".$cat_term_id." current-cat", $listcat);
if ( in_category( $cat_term_id ) || post_is_in_descendant_category( $cat_term_id )) {
echo $listcat;
}
}
?>
</ul>
and here is the result :
http://i.stack.imgur.com/buYyl.jpg
I want the result will be like this :
http://i.stack.imgur.com/U3Pc6.jpg
I think this might work for you, but I'm not exactly sure which theme file you're referencing above.
<?php $parent_cat_id = 1; // Change this ID to match the ID value of the "Sepeda" category ?>
<?php $categories = get_categories( "child_of=$parent_cat_id" ); ?>
<?php if ($categories) : ?>
<ul id="category-list">
<?php // Print the link for 'Sepeda' ?>
<?php echo "<li class='category-name'><a href='" . get_category_link($parent_cat_id) . "'>" . get_cat_name($parent_cat_id) . "</a></li>"; ?>
<?php // Loop through the sub-categories of 'Sepeda' and print the names and links ?>
<?php foreach ($categories as $cat) {
echo "<li class='category-name'><a href='" . get_category_link( $cat->term_id ) . "'>" . $cat->name . "</a></li>";
} ?>
<?php wp_reset_query(); // Restore global post data ?>
</ul>
<?php endif; ?>
Then you could use this CSS to style the category list appropriately:
#category-list {
width: 250px;
padding: 5px;
background: white;
list-style: none;
}
.category-name {
background-color: #694489;
color: white;
min-height: 40px;
text-align: center;
line-height: normal;
padding-top: 10px;
}
.category-name + .category-name {
margin-top: 10px;
}
I am using wordpress and wants to add pagination to posts . code is ok bot ot is not working in chrome.When i am clicking on the pagination it goes to the current page and if i click on the next and previous link it goes to home url But in mozila and other browsers it is working fine . my code is
<?php
if ( !function_exists( 'appcara_pagination' ) ) {
function appcara_pagination($total) {
$prev_arrow = is_rtl() ? 'next' : 'prev';
$next_arrow = is_rtl() ? 'prev' : 'next';
global $wp_query;
//$total = $wp_query->max_num_pages;
//$total="10";
$big = 999999999; // need an unlikely integer
if( $total > 1 ) {
if( !$current_page = get_query_var('paged') )
$current_page = 1;
if( get_option('permalink_structure') ) {
$format = '/%#%/';
} else {
$format = '&paged=%#%';
}
echo paginate_links(array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => $format,
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'mid_size' => 3,
'type' => 'list',
'prev_text' => $prev_arrow,
'next_text' => $next_arrow,
) );
}
}
}
function appcara_paginate_links( $args = '' ) {
$defaults = array(
'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
'total' => 1,
'current' => 0,
'show_all' => false,
'prev_next' => true,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'end_size' => 1,
'mid_size' => 2,
'type' => 'plain',
'add_args' => false, // array of query args to add
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
);
$args = wp_parse_args( $args, $defaults );
extract($args, EXTR_SKIP);
// Who knows what else people pass in $args
$total = (int) $total;
if ( $total < 2 )
return;
$current = (int) $current;
$end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default.
$mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
$add_args = is_array($add_args) ? $add_args : false;
$r = '';
$page_links = array();
$n = 0;
$dots = false;
$prev_link = '<p class="prev-div" ><span class="prev-click"></span></p>';
if ( $prev_next && $current && 1 < $current ) :
$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
$link = str_replace('%#%', $current - 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
/**
* Filter the paginated links for the given archive pages.
*
* #since 3.0.0
*
* #param string $link The paginated link URL.
*/
$prev_link = '<a class="prev-div" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '"><span class="prev-click"></span></a>';
endif;
for ( $n = 1; $n <= $total; $n++ ) :
if ( $n == $current ) :
$page_links[] = "<h3 class='page-numbers'>" . $before_page_number . number_format_i18n( $n ) . $after_page_number . "</h3>";
$dots = true;
else :
if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
$link = str_replace('%_%', 1 == $n ? '' : $format, $base);
$link = str_replace('%#%', $n, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
/** This filter is documented in wp-includes/general-template.php */
$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $before_page_number . number_format_i18n( $n ) . $after_page_number . "</a>";
$dots = true;
elseif ( $dots && !$show_all ) :
$page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>';
$dots = false;
endif;
endif;
endfor;
$next_link = '<p class="next-div" ><span class="next-click"></span></p>';
if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
$link = str_replace('%_%', $format, $base);
$link = str_replace('%#%', $current + 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
/** This filter is documented in wp-includes/general-template.php */
//$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
$next_link = '<a class="next-div" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '"><span class="next-click"></span></a>';
endif;
switch ( $type ) :
case 'array' :
return $page_links;
break;
case 'list' :
$r.='<div class="pagination">';
$r.=$prev_link;
$r .= "<ul class='page-numbers'>\n\t<li>";
$r .= join("</li>\n\t<li>", $page_links);
$r .= "</li>\n</ul>\n";
$r.=$next_link;
$r.='<div class="clear"></div></div>';
break;
default :
$r = join("\n", $page_links);
break;
endswitch;
return $r;
}
?>
calling this function
<?php
//WordPress loop for custom post type
$url=explode('/',$_SERVER['REQUEST_URI']);
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$my_query = new WP_Query('post_type=blogs&posts_per_page=10&paged='.$url['4']);
$total=wp_count_posts('blogs');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div id="blogs">
<div class="content_blog custom_post" >
<h2><?php the_title(); ?></h2>
<i><?php echo get_the_date('', $post->ID).'-'.get_the_time('', $post->ID); ?></i>
<?php the_excerpt();
$term_list = wp_get_post_terms($post->ID, 'blog-cat');
echo "categories:-";
foreach($term_list as $key=>$cat)
{
echo "<a href='".get_term_link(intval($cat->term_id),'blog-cat')."'>".$cat->name.'</a>,';
}
?>
<?php ?>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php appcara_pagination($total->publish/10);
?>
<style>
.pagination ul { list-style: none; border-left: 1px solid #d9d6d6; border-right: 1px solid #d9d6d6; float: left; width: 88%; }
.pagination ul li { display: inline-block; }
.pagination ul li a { display: block; font-size: 16px; font-weight: 600; color: #515050; padding: 6px 2px; }
.prev-div, .next-div { text-align: center; float: left; width: 68px; }
.prev-click, .next-click { display: inline-block; width: 10px; height: 16px; margin: 9px 0 0; }
.prev-click { background-position: -280px -311px; }
.next-click { background-position: -280px -331px; }
.prev-click:hover, .prev-div:hover .prev-click { background-position: -298px -311px; }
.next-click:hover { background-position: -301px -331px; }
.pagination ul li a:hover { color: #d75c43; }
</style>
You can use this code to functions.php file it's working fine..
/*************************************
* Wordpress pagination
**************************************/
function pagination($pages = '', $range = 3)
{
$showitems = ($range * 3)+1;
global $paged; if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages)
{ $pages = 1; } }
if(1 != $pages)
{ echo "<div class='navigation'>";?>
<?php previous_posts_link();
echo "<div class='pagination'><ul>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a rel='nofollow' href='".get_pagenum_link(1)."'>« First</a></li>";
if($paged > 1 && $showitems < $pages) echo "<li><a rel='nofollow' href='".get_pagenum_link($paged - 1)."' class='inactive'>‹ Previous</a></li>";
for ($i=1; $i <= $pages; $i++)
{ if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{ echo ($paged == $i)? "<li class='current'><span class='currenttext'>".$i."</span></li>":"<li><a rel='nofollow' href='".get_pagenum_link($i)."' class='inactive'>".$i."</a></li>";
} } if ($paged < $pages && $showitems < $pages) echo "<li><a rel='nofollow' href='".get_pagenum_link($paged + 1)."' class='inactive'>Next ›</a></li>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a rel='nofollow' class='inactive' href='".get_pagenum_link($pages)."'>Last »</a>";
echo "</ul></div>";?>
<?php next_posts_link();
echo "</div>"; }
}
Use this on index file:
<?php pagination();?>
I have designed a site.
as you can see the learnmore image isnt getting on top of the slideshow images.
u have the following php code
<?php
$directory = 'uploads';
$learnmore_img_path='learnmore';
echo'<div style="position: relative; ">';
try {
// Styling for images
echo "<div id=\"myslides\" style='position: relative; z-index:99999;'>";
foreach ( new DirectoryIterator("../" . $directory) as $item ) {
if ($item->isFile()) {
$path = "/" . $directory . "/" . $item;
echo "<img src=\"" . $path . "\" width=861 height=443 href='#' style='position: relative;'/>";
$learnmore_img_path='learnmore';
$path1="/" . $learnmore_img_path . "/" . 'learnmore.jpg';
}
}
echo "</div>";
$path1="/" . $learnmore_img_path . "/" . 'learnmore.jpg';
echo '<a href="#" id="examplelink">';
echo "<img src=\"" . $path1 . "\" width=160 height=30 style='z-index:32111;; p osition: absolute; top: -75; left: 370;'/>";
echo '</a>';
echo "</div >";
}
catch(Exception $e) {
echo 'No images found for this player.<br />';
}
?>
i dont know why ?
is it because of z-index?
any help appreciated..
Have you tried increasing the z-index of the "learn more" link ?
Give the div containing the slide show less z-index and give the link "learn more" greater z-index value.
Add position: relative on both elements. Then you can adjust level with z-index (CSS)