Archive pages not working (WordPress) - php

I'm having some problems with my archives pages. See: the page loads (as you can see at the Title) here: http://plugcitarios.com/category/eventos/ and here http://plugcitarios.com/category/entretenimento/ but the content/posts is the same at every category I select.
This is the header.php
<!DOCTYPE html>
<html lang="<?php bloginfo('language'); ?>">
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<title><?php wp_title(''); ?></title>
<link href="<?php echo get_template_directory_uri(""); ?>/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="full-width">
<div class="container">
<div class="logo">
<h1><img src="<?php echo get_template_directory_uri(""); ?>/images/logo.png"></h1>
</div>
<div class="social">
<ul>
<li><img src="<?php echo get_template_directory_uri(""); ?>/images/social-instagram.png"></li>
<li><img src="<?php echo get_template_directory_uri(""); ?>/images/social-facebook.png"></li>
<li><img src="<?php echo get_template_directory_uri(""); ?>/images/social-twitter.png"></li>
<li><img src="<?php echo get_template_directory_uri(""); ?>/images/social-youtube.png"></li>
<li><img src="<?php echo get_template_directory_uri(""); ?>/images/social-feed.png"></li>
</ul>
</div>
</div>
</header>
<?php global $post;
if ( is_home() ) { ?>
<section class="content container">
<?php query_posts('category_name=destaque&posts_per_page=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="imagem-destaque">
<a href="<?php the_permalink() ?>"><?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'home1' );
}
?></a>
<div class="meta-destaque">
<span class="categoria-destaque"><ul>
<li>
<?php
$category = get_the_category();
if($category[0]){
echo ''.$category[0]->cat_name.'';
}
?>
</li>
</ul></span>
<h3><?php the_title(); ?></h3>
</div>
</div>
<?php endwhile;?>
<?php rewind_posts(); ?>
<?php wp_reset_query(); ?>
<?php query_posts('category_name=mini-destaque&posts_per_page=2'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="micro-destaque">
<a href="<?php the_permalink() ?>"><?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'home2' );
}
?></a>
<div class="micro-meta-destaque">
<span class="micro-categoria-destaque"><ul>
<li>
<?php
$category = get_the_category();
if($category[0]){
echo ''.$category[0]->cat_name.'';
}
?>
</li>
</ul></span>
<h3><?php the_title(); ?></h3>
</div>
</div>
<?php endwhile;?>
<?php rewind_posts(); ?>
<?php wp_reset_query(); ?>
</section>
<div class="clearfix"></div>
<?php } else { ?>
<?php } ?>
<nav class="container menu-topo">
<?php wp_nav_menu( array('menu' => 'topo' )); ?>
</nav>
And this is the archive.php
<?php get_header(); ?>
<section class="website-content container">
<section class="posts">
<?php rewind_posts(); ?>
<?php
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }
query_posts('posts_per_page=10&paged=' . $paged);
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="meta">
<div class="date">
<?php the_time('j \d\e F') ?>
</div>
<div class="categoria">
<ul>
<li>
<?php
$category = get_the_category();
if($category[0]){
echo ''.$category[0]->cat_name.'';
}
?>
</li>
</ul>
</div>
<div class="author">
postado por <?php the_author_posts_link() ?>
</div>
</div>
<h2><?php the_title(); ?></h2>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<div class="text-article">
<?php the_excerpt(); ?>
</div>
</article>
<?php endwhile; else: ?>
<article>
<p>Nenhum post encontrado.</p>
</article>
<?php endif; ?>
<?php wp_pagenavi(); ?>
</section>
<aside class="sidebar">
<?php get_sidebar(); ?>
</aside>
</section>
<?php get_footer(); ?>
Any Idea? :(

It was a bug at index.php. Loop problems. Fixed it.

Related

How Do I Add More Latest Post To Homepage

I can work pretty good with CSS and HTML but know nothing about PHP. I'm working on a wordpress client project and he wants more than one Latest Post/Recent Post to display on the static homepage. I'm pulling my hair out trying to figure this out. From the posted code, can someone show me what to delete and what to replace it with to make 5 of the most latest post appear? I really appreciate everyone's help.
<?php
/**
* Template Name: Homepage
*/
?>
<?php $mts_options = get_option(MTS_THEME_NAME); ?>
<?php get_header(); ?>
<?php if ($mts_options['mts_banner_show'] == '1') { ?>
<div class="b_first">
<div class="main-container">
<div class="container">
<div class="blog_first">
<!--first content-->
<div id="first_b">
<div class="b_right" <?php if ( isset( $_GET['mailchimp_signup'] ) || !empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="front-view-content">
<?php echo $mts_options['mts_banner_texts']; ?>
</div>
<?php if(!empty($mts_options['mts_button_text'])) { ?>
<div class="readMore" style="background:<?php echo $mts_options['mts_banner_button_bg']; ?>">
<?php echo $mts_options['mts_button_text']; ?>
<?php if(!empty($mts_options['mts_arrow_image'])) { ?>
<div class="b_dollor">
<img src="<?php echo $mts_options['mts_arrow_image']; ?>">
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<!--Rightside Content-Option-1-->
</div>
<div id="second_b" <?php if ( !isset( $_GET['mailchimp_signup'] ) && empty( $_GET['aweber_signedup'] ) ) echo 'style="display:none;"'; ?>>
<div class="blog_first_alternative">
<h2 class="front-view-title">
<?php echo $mts_options['mts_banner_title']; ?>
</h2>
<div class="form_wrap">
<?php if(!empty($mts_options['mts_form_image'])) { ?>
<div class="form_wrap_left">
<img src="<?php echo $mts_options['mts_form_image']; ?>">
</div>
<?php } ?>
<div class="form_wrap_right">
<?php dynamic_sidebar('Home Subscribe Widget'); ?>
</div>
</div>
</div>
<!--Rightside content alternative option-->
<script type="text/javascript">
function hide_b() {
jQuery('#first_b').hide();
jQuery('#second_b').show();
}
</script>
</div>
</div>
<!--End of first content-->
</div>
</div>
</div>
<?php } ?>
<div class="main-container">
<div id="page">
<div class="artcl article">
<div id="content_box">
<?php if ($mts_options['mts_banner2_show'] == '1') { ?>
<!--Second Content-->
<div class="blog_second">
<div class="b_left">
<h2 class="front-view-title">
<?php echo $mts_options['mts_social_title']; ?>
</h2>
<?php if ( !empty($mts_options['mts_banner_social']) && is_array($mts_options['mts_banner_social'])) { ?>
<div class="social-icons">
<ul>
<?php foreach( $mts_options['mts_banner_social'] as $header_icons ) : ?>
<?php if( ! empty( $header_icons['mts_banner_icon'] ) && isset( $header_icons['mts_banner_icon'] ) ) : ?>
<li><span class="fa fa-<?php print $header_icons['mts_banner_icon'] ?>"></span></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php } ?>
</div>
<div class="b_right">
<h2 class="front-view-title">
<?php echo $mts_options['mts_books_title']; ?>
</h2>
<div class="b_readings">
<ul>
<?php if(!empty($mts_options['mts_books_image'])){ ?>
<?php foreach( $mts_options['mts_books_image'] as $slide ) : ?>
<li> <?php echo wp_get_attachment_image( $slide['mts_book_image'], false, array('title' =>'') ); ?></li>
<?php endforeach; ?>
<li class="more-books"><?php echo $mts_options['mts_more_book_text']; ?><i class="fa fa-angle-double-right"></i></li>
<?php } ?>
</ul>
</div>
</div>
</div>
<?php } ?>
<?php if(!empty($mts_options['mts_featured_posts']) && !empty($mts_options['mts_featured_post_cat'])) { ?>
<div class="home_article">
<?php
$featured_cat = implode( ",", $mts_options['mts_featured_post_cat'] );
$featured_query = new WP_Query('cat='.$featured_cat.'&posts_per_page=5');
if ($featured_query->have_posts()) : while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>
<article class="latestPost featuredpost excerpt">
<!--Featured Post-->
<header>
<h3 class="title front-view-title"><?php echo get_the_category_by_ID($featured_cat); ?></h3>
<?php if(has_post_thumbnail()) { ?>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?> <?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
<?php } ?>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>
"><?php the_title(); ?></a>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(45); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php endwhile; wp_reset_query(); endif; ?>
<?php $j = 0;
if (get_query_var('page') > 1) {
$paged = get_query_var('page');
} elseif (get_query_var('paged')) {
$paged = get_query_var('paged');
} else {
$paged = 1;
}
$args= array('paged' => $paged, 'post_type' => 'post');
query_posts($args);
if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<?php if($j ==0){ ?>
<article class="latestPost latestpost excerpt">
<!--Latest Post-->
<header>
<h3 class="title front-view-title"><?php _e('Latest Post','steadyincome'); ?></h3>
<a href="<?php the_permalink() ?>" title="Menu widget article" id="featured-thumbnail">
<div class="featured-thumbnail">
<?php the_post_thumbnail('steadyincome-featured',array('title' => '')); ?>
<?php if (function_exists('wp_review_show_total')) wp_review_show_total(true, 'latestPost-review-wrapper'); ?>
</div>
</a>
</header>
<div class="latestpost_wrap">
<h2 class="front-view-title">
<?php the_title(); ?>
</h2>
<?php mts_the_postinfo( 'home' ); ?>
<div class="front-view-content">
<?php echo mts_excerpt(40); ?>
</div>
<?php mts_readmore(); ?>
</div>
</article>
<?php } ?>
<?php $j++; endwhile; wp_reset_query(); endif; ?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Looks like you might have some setting in your theme settings. However if you have no setting there.
You can see this line that is limiting latest posts to just one Post:
<?php if($j ==0){ ?>
You may try to change it to number you want to try and see if it loops more posts there:
<?php if($j < 5){ ?>
This should allow the loop to run for five posts now. Give it a try and see if it helps.

Centering an objekt in php template. How?

I have a little problem with aligning a logo with some text in wordpress.
The more transparent logo is where I want my logo to be. It is in my header.php in my wordpress theme "Creator World".
I Really dont know what to do I have tried to research and I couldn't find anything. Hope you can help me 😀
The more transparent logo and the arrow is sat in, in an design app
Here is my php code for my header.php in wordpress
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div class="container">
*
* #package Creator World
*/
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="pagewrap">
<div class="headertop">
<div class="container">
<?php if ( ! dynamic_sidebar( 'header-info' ) ) : ?>
<?php endif; // end header widget area ?>
</div><!-- .container -->
</div><!-- .headertop -->
<div class="header">
<div class="container">
<div class="logo">
<?php creator_world_the_custom_logo(); ?>
<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php bloginfo('name'); ?>
</a></h1>
<p>
<?php bloginfo('description'); ?>
</p>
</div><!-- logo -->
<div class="toggle"> <a class="toggleMenu" href="#">
<?php _e('Menu','creator-world'); ?>
</a> </div> <!-- toggle -->
<div class="sitenav">
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>
</div>
<!-- site-nav -->
<div class="clear"></div>
</div><!-- container -->
</div><!--.header -->
<?php if ( is_front_page() && !is_home() ) { ?>
<?php $hideslide = get_theme_mod('disabled_slides', '1'); ?>
<?php if($hideslide == ''){ ?>
<?php for($sld=7; $sld<10; $sld++) { ?>
<?php if( get_theme_mod('page-setting'.$sld)) { ?>
<?php $slidequery = new WP_query('page_id='.get_theme_mod('page-setting'.$sld,true)); ?>
<?php while( $slidequery->have_posts() ) : $slidequery->the_post();
$image = wp_get_attachment_url( get_post_thumbnail_id($post->ID));
$img_arr[] = $image;
$id_arr[] = $post->ID;
endwhile;
}
}
?>
<?php if(!empty($id_arr)){ ?>
<div id="slider" class="nivoSlider">
<?php
$i=1;
foreach($img_arr as $url){ ?>
<?php if(!empty($url)){ ?>
<img src="<?php echo $url; ?>" title="#slidecaption<?php echo $i; ?>" />
<?php }else{ ?>
<img src="<?php echo esc_url( get_template_directory_uri() ) ; ?>/images/slides/slider-default.jpg" title="#slidecaption<?php echo $i; ?>" />
<?php } ?>
<?php $i++; } ?>
</div>
<?php
$i=1;
foreach($id_arr as $id){
$title = get_the_title( $id );
$post = get_post($id);
$content = esc_html( wp_trim_words( $post->post_content, 20, '' ) );
?>
<div id="slidecaption<?php echo $i; ?>" class="nivo-html-caption">
<div class="slide_info">
<h2><?php echo $title; ?></h2>
<p><?php echo $content; ?></p>
</div>
</div>
<?php $i++; } ?>
<?php wp_reset_postdata(); ?>
<div class="clear"></div>
<?php } ?>
<?php } } ?>
<?php if ( is_front_page() && ! is_home() ) { ?>
<?php $hidewelcome = get_theme_mod('disabled_welcome', '1'); ?>
<?php if($hidewelcome == ''){ ?>
<section id="welcomesection">
<div class="container">
<div class="welcomebx">
<?php if( get_theme_mod('page-setting1')) { ?>
<?php $queryvar = new WP_query('page_id='.get_theme_mod('page-setting1' ,true)); ?>
<?php while( $queryvar->have_posts() ) : $queryvar->the_post();?>
<h2 class="headingtitle">
<?php the_title(); ?>
</h2>
<?php the_content(); ?>
<div class="clear"></div>
<?php endwhile;
wp_reset_postdata(); ?>
<?php } ?>
</div> <!-- welcomewrap-->
<div class="clear"></div>
</div> <!-- container -->
</section>
<?php } ?>
<?php $hidepgbxes = get_theme_mod('disabled_pageboxes', '1'); ?>
<?php if($hidepgbxes == ''){ ?>
<section id="wrapsecond">
<div class="container">
<div class="services-wrap">
<?php for($p=1; $p<5; $p++) { ?>
<?php if( get_theme_mod('page-column'.$p,false)) { ?>
<?php $querymy = new WP_query('page_id='.get_theme_mod('page-column'.$p,true)); ?>
<?php while( $querymy->have_posts() ) : $querymy->the_post(); ?>
<div class="fourbox <?php if($p % 4 == 0) { echo "last_column"; } ?>">
<?php if(has_post_thumbnail() ) { ?>
<div class="thumbbx"><?php the_post_thumbnail();?> </div>
<?php } ?>
<div class="pagecontent">
<h3><?php the_title(); ?></h3>
<p><?php echo wp_trim_words( get_the_content(), 20, '...' ); ?></p>
<a class="pagemore" href="<?php the_permalink(); ?>">
<?php _e('Read More','creator-world'); ?>
</a>
</div>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
<?php } } ?>
<div class="clear"></div>
</div> <!-- services-wrap-->
</div> <!-- container -->
</section>
<?php } ?>
<?php } ?>
You can't center a logo through php. The right way will be css. Search by css and you will find many ways to achieve this. Or post the link of your site so that we can help you.
Try changing the code to the following, adding a new div with class brand-name and leaving only the logo in the one with logo class.
<div class="header">
<div class="container">
<div class="brand-name">
<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php bloginfo('name'); ?>
</a></h1>
<p>
<?php bloginfo('description'); ?>
</p>
</div>
<div class="logo">
<?php creator_world_the_custom_logo(); ?>
</div><!-- logo -->
<div class="toggle"> <a class="toggleMenu" href="#">
<?php _e('Menu','creator-world'); ?>
</a> </div> <!-- toggle -->
<div class="sitenav">
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>
</div>
<!-- site-nav -->
<div class="clear"></div>
</div><!-- container -->
</div><!--.header -->
Then, add the following lines in CSS:
.brand-name, .logo {
display: inline-block;
}
try wrapping the logo and title to the individual div elements
<div class="header">
<div class="container">
<div class="brand-title pull-left">
<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php bloginfo('name'); ?>
</a></h1>
<p>
<?php bloginfo('description'); ?>
</p>
</div><!-- Brand Title -->
<div class="brand-logo pull-left">
<?php creator_world_the_custom_logo(); ?>
</div><!-- Brand logo -->
<div class="toggle"> <a class="toggleMenu" href="#">
<?php _e('Menu','creator-world'); ?>
</a> </div> <!-- toggle -->
<div class="sitenav">
<?php wp_nav_menu(array('theme_location' => 'primary')); ?>
</div>
<!-- site-nav -->
<div class="clear"></div>
</div><!-- container -->
</div><!--.header -->
and then add the following code to your CSS file (usually this is style.css)
.pull-left {
float: left;
}

Advanced Custom field for each post in WordPress

I am using Advanced Custom Fields in order to show different banner image for each language with qTranslate plugin.
<?php get_header(); ?>
<section id="linea">
<?php if(qtrans_getLanguage()=='en') {
?>
<img src="<?php the_field('banner')?>">
<?php }
else if(qtrans_getLanguage()=='es') {?>
<img src="<?php the_field('banner_image_es')?>">
<?php }?>
</section>
<section id="categoria1">
<div class="pagewidth clearfix">
<div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<h1 class="categoria-title"><span class="left"></span><b><?php single_term_title(); ?></b><span class="right"></span></h1>
</div>
</section>
<section id="categoria2">
<div class="pagewidth clearfix">
<ul class="product-list">
<?php $my_query = new WP_Query(array('post_type' => 'productos','taxonomy'=>'categoria','term'=>'conformink-cunero-luxy','paged' => get_query_var('paged'))); ?>
<?php while ( $my_query->have_posts() ) : $my_query->the_post();?>
<li>
<h5><a style="color: #f79646;" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
<a class="verdetalle" href="<?php the_permalink(); ?>"><?php if( qtranxf_getLanguage() == 'es' ){ ?>Ver detalle<?php }else { ?>See More<?php } ?></a>
<!-- <p><?php echo substr(get_the_excerpt(), 0,120); ?></p> -->
<?php the_post_thumbnail('thumbnail'); ?>
</li>
<?php
endwhile;
wp_pagenavi( array( 'query' => $my_query ) );?>
<?php wp_reset_query(); ?>
</ul>
</div>
</section>
<?php get_footer(); ?>
The problem is that it keep showing the image of only one post on all templates, although I have already assigned the different images to different categories.
Can anyone help?
If you want the banner to show up on every post you'll have to move the section inside the loop:
<section id="categoria2">
<div class="pagewidth clearfix">
<ul class="product-list">
<?php
$my_query = new WP_Query(array('post_type' => 'productos','taxonomy'=>'categoria','term'=>'conformink-cunero-luxy','paged' => get_query_var('paged')));
if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post();?>
<li>
<section id="linea">
<?php if ( qtrans_getLanguage() == 'en' ) : ?>
<img src="<?php the_field('banner'); ?>">
<?php elseif ( qtrans_getLanguage() == 'es' ) : ?>
<img src="<?php the_field('banner_image_es'); ?>">
<?php endif; ?>
</section>
<h5><a style="color: #f79646;" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
<a class="verdetalle" href="<?php the_permalink(); ?>"><?php if( qtranxf_getLanguage() == 'es' ){ ?>Ver detalle<?php }else { ?>See More<?php } ?></a>
<!-- <p><?php echo substr(get_the_excerpt(), 0,120); ?></p> -->
<?php the_post_thumbnail('thumbnail'); ?>
</li>
<?php
endwhile; endif;
wp_pagenavi( array( 'query' => $my_query ) );
wp_reset_query(); ?>
</ul>
</div>
</section>

Where to add google custom search code in search php

I need an advice on where to add my google custom search engine code in the search.php file ?
here is the php file:
note that endwhile and endif are included, I have checked on youtube and I tried to delete the code between (if have post) and (endif) and add the google code there but it did not work..
<?php $mts_options = get_option('point'); ?>
<?php get_header(); ?>
<div id="page" class="home-page">
<div class="content">
<div class="article">
<h1 class="postsby">
<span><?php _e("Search Results for:", "mythemeshop"); ?></span> <?php the_search_query(); ?>
</h1>
<?php $j=0; $i =0; if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="<?php echo 'pexcerpt'.$i++?> post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">
<?php if ( has_post_thumbnail() ) { ?>
<?php echo '<div class="featured-thumbnail">'; the_post_thumbnail('featured',array('title' => '')); echo '</div>'; ?>
<?php } else { ?>
<div class="featured-thumbnail">
<img src="<?php echo get_template_directory_uri(); ?>/images/nothumb.png" class="attachment-featured wp-post-image" alt="<?php the_title(); ?>">
</div>
<?php } ?>
<div class="featured-cat"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></div>
</a>
<header>
<h2 class="title">
<?php the_title(); ?>
</h2>
<div class="post-info"><span class="theauthor"><?php the_author_posts_link(); ?></span> | <span class="thetime"><?php the_time( get_option( 'date_format' ) ); ?></span></div>
</header><!--.header-->
<div class="post-content image-caption-format-1">
<p>
<?php echo mts_excerpt(29);?>
<span class="readMore"><?php _e('Read More','mythemeshop'); ?></span>
</p>
</div>
</article>
<?php endwhile; else: ?>
<div class="no-results">
<h5><?php _e('No Results found. We apologize for any inconvenience, please hit back on your browser or use the search form below.', 'mythemeshop'); ?></h5>
<?php get_search_form(); ?>
</div><!--noResults-->
<?php endif; ?>
<!--Start Pagination-->
<?php if ( isset($mts_options['mts_pagenavigation']) && $mts_options['mts_pagenavigation'] == '1' ) { ?>
<?php $additional_loop = 0; global $additional_loop; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination">
<ul>
<li class="nav-previous"><?php next_posts_link( __( '← '.'Older posts', 'mythemeshop' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Newer posts'.' →', 'mythemeshop' ) ); ?></li>
</ul>
</div>
<?php } wp_reset_query(); ?>
<!--End Pagination-->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Regards !!
Just Create A New File Called searchform.php and paste your Google Custom Search Code There.
I managed to change where to add the code and here is the full code of search.php
<?php $mts_options = get_option('point'); ?>
<?php get_header(); ?>
<div id="page" class="home-page">
<div class="content">
<div class="article">
<h1 class="postsby">
<span><?php _e("Search Results for:", "mythemeshop"); ?></span> <?php the_search_query(); ?>
</h1>
<?php $j=0; $i =0; if (have_posts()) : while (have_posts()) : the_post(); ?>
<script>
(function() {
var cx = '000306723311332550300:tfoukb5efrq';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
</article>
<?php endwhile; else: ?>
<div class="no-results">
<h5><?php _e('No Results found. We apologize for any inconvenience, please hit back on your browser or use the search form below.', 'mythemeshop'); ?></h5>
<?php get_search_form(); ?>
</div><!--noResults-->
<?php endif; ?>
<!--Start Pagination-->
<?php if ( isset($mts_options['mts_pagenavigation']) && $mts_options['mts_pagenavigation'] == '1' ) { ?>
<?php $additional_loop = 0; global $additional_loop; mts_pagination($additional_loop['max_num_pages']); ?>
<?php } else { ?>
<div class="pagination">
<ul>
<li class="nav-previous"><?php next_posts_link( __( '← '.'Older posts', 'mythemeshop' ) ); ?></li>
<li class="nav-next"><?php previous_posts_link( __( 'Newer posts'.' →', 'mythemeshop' ) ); ?></li>
</ul>
</div>
<?php } wp_reset_query(); ?>
<!--End Pagination-->
</div>
<?php get_footer(); ?>

wordpress the_content() == null although $page->content returns value

Any ideas why the_content() is returning null? When I use $page->content in the same place, this returns the correct value from database.
<?php get_header(); ?>
<div id="main" class="clearfix" role="main">
<?php $attachments = new Attachments( 'attachments' ); ?>
<?php if( $attachments->exist() ) : ?>
<div id="myCarousel" class="carousel">
<!-- Carousel items -->
<div class="carousel-inner">
<?php $i = 0; while( $attachments->get() ) : $i++; ?>
<div class="<?php if($i == 1){ echo 'active'; } ?> item item-<?php echo $attachments->id(); ?>">
<?php echo $attachments->image( 'featured-home' ); ?>
<?php if($attachments->field('caption')){ ?>
<div class="carousel-caption">
<?php echo $attachments->field('caption'); ?>
</div>
<?php } ?>
</div>
<?php endwhile; ?>
</div>
<?php if($i > 1) { ?>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
<?php } ?>
<div class="carousel-overlay icons">
Facebook
Twitter
YouTube
RSS Feed
</div>
</div>
<?php endif; ?>
<?php if (have_posts()) : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(array('row-fluid','clearfix')); ?> role="article">
<div id="content" class="span8">
<header>
<h1><?php echo get_post_meta($post->ID, 'custom_tagline' , true);?></h1>
<?php the_content(); ?>
</header>
<section class="post_content hasSidebar">
<?php query_posts('showposts=10');
while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<header>
<?php the_post_thumbnail( 'wpbs-featured' ); ?>
<h2><?php the_title(); ?></h2>
<?php if(get_comments_number() >= 1): ?>
<a href="<?php comments_link() ?>" title="<?php comment_date() . ' - ' . comment_excerpt(); ?>" <?php comment_class(); ?>><?php comments_number(); ?></a>
<?php endif; ?>
<p class="meta"><?php _e("Posted", "bonestheme"); ?> <time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_date(); ?></time> <?php _e("by", "bonestheme"); ?> <?php the_author_posts_link(); ?> <span class="amp">&</span> <?php _e("filed under", "bonestheme"); ?> <?php the_category(', '); ?>.</p>
</header>
<section class="post_content">
<?php the_excerpt(); ?>
</section>
<?php if(has_tag()): ?>
<footer>
<p class="tags"><?php the_tags('<span class="tags-title">' . __("Tags","bonestheme") . ':</span> ', ' ', ''); ?></p>
</footer>
<?php endif; ?>
</article>
<?php endwhile ?>
<?php content_paging_nav('nav-below'); ?>
</section>
<footer>
<p class="clearfix"><?php the_tags('<span class="tags">' . __("Tags","bonestheme") . ': ', ', ', '</span>'); ?></p>
</footer>
</div>
<?php get_sidebar('sidebar2'); ?>
</article>
<?php else : ?>
<article id="post-not-found">
<header>
<h1><?php _e("Not Found", "bonestheme"); ?></h1>
</header>
<section class="post_content">
<p><?php _e("Apologies, but no results were found. Perhaps searching will help find a related post.", "bonestheme"); ?></p>
</section>
<footer>
</footer>
</article>
<?php endif; ?>
</div> <!-- end #main -->
<?php //get_sidebar(); // sidebar 1 ?>
<?php get_footer(); ?>
You're not in a WP loop. You should call e.g. the_post() to set up WP's slew of globals.
Beware of nested WP loops, too. There used to be a gazillion bugs related to them, and there might still be a few lying around just waiting to bite.

Categories