So I'm working on my blog page which uses a different page template, PHP isn't exactly my forte, and I feel like it should be a simple solution to remove the page header, but its all a bit out of my reach. This is my site, and my code looks like this:
<?php
/**
* Template Name: Blog
*/
get_header();
get_template_part( "closer" ); ?>
<div class="container">
<div class="row">
<div id="primary" <?php bavotasan_primary_attr(); ?>>
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;
bavotasan_pagination();
else :
get_template_part( 'content', 'none' );
endif;
?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
try to change this way,
Appearance > Editor > content-page.php (on the right side bar)>
Find: this statement
the_title();
and simply comment it out.
//the_title();
or do the above change in content.php file
I gave up, and used display: none in my CSS. Probably not the best way to go, but it works.
Related
I'm trying to move the post's featured image below the post title in the Marketify theme, however I can't seem to find this hidden in the code.
Can anybody please help me find the code for the post's featured image? How do I move this below the post title?
Firstly, create a Child Theme for your WordPress Theme.
Then look in '/wp-content/themes/[theme-name], where you should find a file entitled 'single.php'. Copy this into your child theme, taking care to ensure you replicate the same directory hierarchy. The 'single.php' is usually the name of your default Blog Post Template.
Open up the 'single.php' file, which you have saved within your child theme, with a programme such as Notepad++ (Notepad will also do but is not as easy on the eye).
You should see something like:
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
}?>
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<h1><?php the_title(); ?></h1> //This is the title of your Blog Post.
<div class="entry">
<?php the_content(); ?> //This is the content of your Blog Post.
</div>
<?php endwhile; ?>
<?php endif; ?>
There will be a slight variation in the coding but what you are looking to do is highlight:
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
}?>
and then move this coding to beneath <h1><?php the_title(); ?></h1>. You will need to play around as to where exactly you will need it but I hope this helps get you started.
The reason I have suggested that you do this within a Child Theme is that when the Theme Developer rolls out an update, it will delete any modifications you have made within the parent files.
Good Luck!
Thanks for your comment. I assumed it would be similar to code you've written too, but the title and featured image are hidden in the "do_action( 'marketify_entry_before' );".
get_header(); ?>
<?php do_action( 'marketify_entry_before' ); ?>
<div class="container">
<div id="content" class="site-content row">
<div role="main" id="primary" class="col-xs-12 col-md-8 <?php echo ! is_active_sidebar( 'sidebar-1' ) ? 'col-md-offset-2' : '' ?>">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'single' ); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
None the less, for anyone else with the same problem; I figured out how to hide this section in css like so...
.single .header-outer.has-image .page-header {
display: none;
}
And then could use the standard Wordpress functions to make the title and featured image appear where I wanted.
Thanks :)
Tom
I have a static wordpress front page. I want the code that works on my regular blog template to work on the homepage too.
Currently, it only shows one post. The code in the main index.php is this...
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
content.php calls this....
<div class="col-md-4">
<?php the_excerpt(); ?>
</div><!-- /col-md-4 -->
This works great while on the blog page. But i can't get this exact same content on to the static home page. I know I need a different query for homepage but no idea what that is. Any help appreciated!
Your code looks right to me, you can try to reset the loop and query the posts again.
<?php
rewind_posts();
query_posts( $args );
while ( have_posts() ) : the_post();
?>
<!-- Do stuff... -->
<?php endwhile; ?>
global $query_string;
query_posts($query_string.'&post_type=post&posts_per_page=15');
Adding this on top of your code should work. Try it out.
I've created a custom template using the twentythirteen template. When I activate the template the blog posts disappear from the front page. I've used the same process to make the new template as I did for my own.
You can see my blog page here, http://www.gnarlydigital.com/blog/ and the new blog that I'm working on is here, http://www.flowdirectpumps.com/news/.
I've tripled checked all the code and both templates are identical. I've uploaded the Gnarly Digital template and it works.
Can anyone see anything obvious?
This is the index.php file
<?php get_header(); ?>
<div class="container pageContent">
<div class="row">
<div class="col-md-12">
<?php if ( have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentythirteen_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>
I am studying wordpress php coding and noticed that these loops are not within a continuous php tag. This is a surprise to me, a beginner, who has read that the statements are delineated by colons or semi colons.
I did not know this works, but obviously it does. Is there a particular reason one would choose this syntax?
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php if ( have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentythirteen_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div><!-- #content -->
</div>
Is there a particular reason one would choose this syntax?
This is called an alternative syntax, and it exists solely for code readability/legibility purposes. See this page for more info.
Good day to all,
I'm new in wordpress. I want to ask on how to display my page content in different div. But when I try this code. It won't display anything, my page won't even load. Any help would be much appreciated. Thanks!
<?php if($_SERVER['REQUEST_URI'] == '/wordpress/?page_id=5'): ?>
<div style="width:960px; float:left;min-height:290px;word-wrap: break-word">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
<?php else: ?>
<div style="width:640px; float:left;min-height:290px;word-wrap: break-word">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
<?php endif;?>
If you have access to the theme files, copy and paste the page.php, rename the duplicate file to page-about.php, where about is the slug of the page. Similarly you can have any number of page duplicates.
To find what is the slug of a page, go to the page editing area, Screen Option > View Slug.