Loki180
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Adding a search to custom themeSorry for all these posts guys, trying to update as I go along. It is working much better now, just one issue with the single.php file
Once a user has searched for a word or phrase it spits out a list of the things it has found, like expected, but once a user clicks on the one they are looking for nothing is displayed other than the title
the fault is with the single.php but i am not sure why it is not displaying.
<?php get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <p>This is single.php</p> <h3><a href='<?php the_permalink(); ?>'><?php the_title(); ?></a></h3> <p><?php the_content(); ?></p> <hr> </main><!-- .site-main --> </div><!-- .content-area --> <?php get_footer(); ?>That is the single.php is but the_content(); is not showing up
Forum: Fixing WordPress
In reply to: Adding a search to custom themeHi guys,
So I have been going through the twenttyTifteen theme pulling out all of the search code.
So far i have the search bar displayed from the widgets, but once I type anything in it goes to another page saying
Search Results For: xxxxBut only if I have searched for something that is on the site, if I searched for something thats not on the site then the page is just blank.
I have so far
page.php
content-search.php
search.php
content.php
single.php
content-page.phpall from the theme into my own theme, but with no victory.
I have added this to the functions.php to make widgets work
function twentyfifteen_widgets_init() { register_sidebar( array( 'name' => __( 'Widget Area', 'twentyfifteen' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentyfifteen' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'twentyfifteen_widgets_init' );I am unsure on if the functions.php needs anything else for the search to work?
Forum: Fixing WordPress
In reply to: Single permalink returning one custom postSorry about the above, This one will be better to understand!
The blow code is from the
single-work.php
$args = array( "post_type" => "work" ); $the_query = new WP_Query($args); ?> <?php if (have_posts() ) : while ($the_query->have_posts() ) : $the_query->the_post(); ?> <h1><?php the_field("name_of_website"); ?></h1> <img class="image-area' src="<?php the_field("image"); ?>'> <p><?php the_field("description"); ?></p> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?>The below code is from the portfolio of the clickable field image
<?php $args = array( 'post_type' => 'work' ); $the_query = new WP_Query($args); ?> <?php if (have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <a href='<?php the_permalink(); ?>'> <li> <img class='image-area' src='<?php the_field('image'); ?>'> </li> </a> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?>When I click on the image WordPress displays all the custom posts and fields from Work I want it to only display the one clicked, I can not remember how to do it!