WordPress: front-page.php, linking to the main homepage - wordpress

So I have a website where a custom front page needed to be built as a static page, to do this I created front-page.php
I believe the original homepage just showed a list of posts.
The issue that I am having is that I want to link the front-page.php to the original front page of the website. I've had a look at using home.php and setting the URL on the front-page.php file to <?php echo get_permalink( get_option( 'page_for_posts' ) ); ?> but this just seemed to link to a single blog post.
Any ideas how I can resolve this?
Thanks in advance.

Go to Settings > Reading and check off A static page, Below it select Home as the Homepage. That should do the trick.

Related

Wordpress website with blog page structure

I've built a website (locally) that works just fine and, I've written the home page content in the Index page as I'm accustomed to and, different templates (page1.php, page2.php) for pages that required different layout for the 'About' and 'Contact' pages etc. Since deciding to add a blog though it has me stumped. I've written a blog page and it looks just fine but when I try to view a post I'm just directed back to index.php. I know it's down to the structure but it's confusing. An index page is mandatory, and you should probably have a front-page.php too. If that's the case..which one should I write my home page on? Index page doesn't show in the reading list and choosing "front page' as a static page works but still the blog links go back to index. If I was to put the content from the index page into front-page.php, what would I have in the index page?
Although the Wordpress docs are good I can't really find anything to suggest which way round all this stuff would be.
Your issue is that WordPress by default uses the index.php file for the blog archive (as well as other archives, etc.) and you need to use front-page.php for a dedicated home page with your custom content.
Read https://developer.wordpress.org/themes/basics/template-hierarchy/ on how to construct a standard WordPress theme with template files that follow a standard hierarchy.
The front-page.php template file is used to render your site’s front
page, whether the front page displays the blog posts index (mentioned
above) or a static page. The front page template takes precedence over
the blog posts index (home.php) template. If the front-page.php file
does not exist, WordPress will either use the home.php or page.php
files depending on the setup in Settings → Reading. If neither of
those files exist, it will use the index.php file.
Duplicate index.php and call it front-page.php. Edit index.php to be a basic template with a standard loop (and none of your home page content) so that it can function as a blog template that displays the_excerpt or the_content, something like this:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<?php endwhile; else: ?>
<?php _e( 'Sorry, no posts matched your criteria.', 'textdomain' ); ?>
<?php endif; ?>
See https://developer.wordpress.org/themes/basics/the-loop/

Can Shortcodes be used in a Static WordPress Homepage?

I have a Static page set as the home page of my wordpress website. It has a custom shortcode to show a woocommerce catalog based on my own meta query.
When I add valid products, it does not show up immediately or even after a while. However, if I publish the static page, then it shows up magically, thus leading to my question.
What are my alternatives, if I want to show my shortcode on a static home page?
I think this is my problem and nothing else, because I tried disabling all plugins and clearing the cache, but still it did not show the latest added products.
You can edit the template of your theme adding the do_shortcode() function where you want the shortcode to be displayed, for example:
<?php echo do_shortcode( '[contact-form-7 id="91" title="quote"]' ); ?>

[coDisplay wordpress posts does not work

I am using the following code in the wordpress theme I created and it does not display anything despite there are 2 posts active! What is wrong?
else :
echo 'No content found';
endif;
?>
Files in theme currently are only index.php, header.php, footer.php and style.css as we are justg beginning to build it
Instead of the error message it prints one word "Home" and home is not even the title of any of the posts? What is wrong?
Thanks
Tim

add page title to latest posts frontpage in wordpress

I set my reading section to latest posts in Wordpress. My homepage logs fine but I would like to add a page title above the posts. I have looked in my theme's files and couldn't find the file to edit. As a test, I tried to add an image to my theme's loop.php and it appeared above the post on my homepage. The location was right but the image appeared on every one of my category blog list pages. How do I add a page title to the homepage that only appears on the homepage above the blog list?
Here are some resources for you to use, WordPress: https://codex.wordpress.org/Function_Reference/get_the_title
Eg:
you can use
<?php echo get_the_title(); ?>
or
<?php echo get_the_title($ID); ?>
There is lot of resources on WordPress, best of luck!

Wordpress function is_front_page() not working

I have a "static" page set up as my front page for Wordpress.
I have this in the index.php file:
<?php
if (is_front_page() || is_home()) {
?><p>TEST FRONT PAGE</p>
<?php
} ?>
For some reason, the "TEST FRONT PAGE" does not show up on the front page, but does show up on the posts page (as it should, for these purposes only)...I'm using Wordpress 3.0, and I tested this on the twentyten template itself!
Anyone know why?
Thanks,
Amit
Because the front page is loading from front-page.php not index.php.
EDIT
It's loading from page.php. You can read more about the template hierarchy here:
http://codex.wordpress.org/Template_Hierarchy
The is_home() tag actually looks for the page where all your recent posts are shown. If you are on the homepage and you are showing recent posts there, is_home() will return true. And if your front page is set static or template, is_home() will return false but will return true for any inner page where your recent posts are being shown.
The is_front_page()
It returns TRUE when the main blog page is being displayed and the Settings->Reading->Front page displays is set to "Your latest posts",
or when is set to "A static page" and the "Front Page" value is the current Page being displayed.
References
Here's Difference between is_home() and is_front_page()! And a reference to Codex Conditional Tags
Putting <?php wp_reset_query(); ?> before the if(is_front_page() || is_home()){}
worked witht he same issue i was having

Resources