Archive Page Template returns posts instead of page content on Polylang second language - wordpress

I have an issue with Polylang and custom archive page template. On my main language my archive page shows page content but on second language it starts looping trough posts.
<?php
/* Template Name: Archive Page Custom */
get_header();
while (have_posts()) : the_post();
the_content();
endwhile;
?>
<?php
get_footer(); ?>
What causes this?
Cheers

I have solved this. It turns out that under Polylang settings I had to uncheck my custom taxonomies because it completely breaks the site.
EDIT: Never mind this doesn't work because as I turn it off it shows posts from all languages on my archive first page. So it still has to be turned off to filter posts between languages.
So the issue remains. Archive page with default language loads content in from the page and secondary language shows posts for some reason instead of content.
EDIT: It was a conflict with archive-portfolio.php template and also I had custom post type slug named same as my secondary translation so the page broke. I had to rename my archive-portfolio.php template to portfoliotemplate.php and it works now.

Related

Custom page template displays the archive template

I have a custom page template named "page-news.php" and it contains
<?php
/*
* Template Name: News
*/
get_header();
?>
test
<?php
wp_footer();
get_footer();
?>
and I then create a page and set the template to "News" but when I view the page, it does not display the contents on the page-news.php custom page template, instead it display the archive.php contents (I have test it, whatever I put unto the archive.php contents, it display on the page that I hook unto the page-news.php custom page template). Any ideas, help please? I'm running WP 4.7.2.
Please rename the file name i.e. from 'page-news.php' to 'news.php' or any other name but don't add 'page-' in the file name & then select the template again for the page in the admin backend.
Hope, this will help you.

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/

WordPress -Why are shortcodes being ignored in my custom post type?

I am using Visual Composer which works great on my posts and pages, however, when I view a custom post type that I created using Visual Composer, all of the shortcodes are ignored so the page looks something like the following...
[vc_row][vc_column][vc_column_text]I am a text box.[/vc_column_text][/vc_column][/vc_row]
My cpt template uses the wordpress loop <?php the_content(); ?> and shotcodes are ignored. My other page templates also use <?php the_content(); ?> but all the Visual Composer shortcodes work perfectly.
I tried replacing my cpt template with my default page template and the shortcodes were still ignored so I don't think it's a template issue because I concluded that using the default page template for a page post works perfectly but using the same template for a cpt post does not work and ignores the shorcodes.
I don't know what is causing this. Any help is appreciated.
Maybe you missed the wp_head(); at the header or wp_footer at the footer

Wordpress: Pages work, Posts don't

First of all, I'm totally new to WordPress so please be patient :)
Anyway, I have created a custom theme with a bunch of pages, a menu and a startpage (index.php), and everything is working fine. I have also created a few posts and those are not working at all. I have created a small loop that display the 5 latest posts on the startpage as links with date, and they show up as intended, but if I click on one of the links the startpage just reloads. As the page has reloaded it displays the correct permalink in the browser address bar, but I'm still stuck on the startpage. Same if I try to preview my posts from WP-admin, it just display my start page.
I have no idea what I'm doing wrong here and I'm no php coder. This is the code I have in my page.php file, maybe there is something wrong with it?
<?php get_header(); ?>
<div class="content">
<?php while ( have_posts() ) : the_post(); the_content(); endwhile; // THE LOOP ?>
</div>
<?php get_footer(); ?>
there is a difference between posts and pages. Try to put this code into a file called index.php so it will work for posts too.
If wordpress cant find a page.php (this is for pages) or single.php (this is for posts) it will look into the index.php as a fallback.
those are the files - enjoy :)
1. style.css: your page styling goes in here.
2. index.php: acts as fallback if the specific php files are not found.
3. single.php: single posts template
4. page.php: single page styling goes here
5. archive.php: acts as archives template (by month, author,...)
6. searchform.php: style and configure your searchform here
... there are many more. here is a cheat sheet with page types / theme structure .If you need further information google for types followed by tutorial
example: wordpress single.php tutorial
all the best
fab

Wordpress ignoring page template from drop down

I am struggling with something that appears to be easy, page templates. I have read plently posts on this, people seem to forget to put the comment at the top of the page and can't get it to show up in the drop down menu on pages. I can do this, my problem is the next stage.
I have written the most basic template (custom-page.php):
<?php
/*
Template Name: Test template
*/
?>
<?php get_header(); ?>
<h1>Teams!</h1>
<?php get_footer(); ?>
It shows up and I can select it on the new page sidebar. However when I visit that new page it seems to have defaulted the archive page using the content template include.
Thanks in advance.
If you put the following in your footer, you should be able to grok some further information about how your template is being selected (and know exactly what might be happening).
<?php global $template;
echo(basename($template)); ?>
Then look for the template name in your footer. It's possible (like #adomnom said) that you have a slug conflict. There are a handful of other strange scenarios that could be caused by plugins, custom functions, or other factors as well.
By the sounds of things, it could be conflicting with another template.
For example, if your page has the slug 'category' and is set to use the custom template 'custom-template.php', it would conflict with (and be overridden by) category.php, which is the default template for showing posts for a specific category.
I recommend changing the slug to see if that's the problem.

Resources