I am using the featured content slider provided as standard in the Twenty Fourteen Wordpress theme. It's doing pretty much everything I want it to do at this point and I have done some basic customisation on it using CSS, however after speaking to a few folk internally they are looking to "insert" this into the main content area of the page.
I've had a look around, and found a suggestion to change the index.php file to change the position of the PHP statement that registers the featured content. After making these changes to my child theme and publishing them nothing happened.
I am at a complete loss as to where to look next or what to change (without trial and error which could break everything!)
It's probably a very simple solution that I'm completely overlooking so apologies if this is the case. This is an internal site so I can't provide any links unfortunately. Many thanks in advance for your help!
Index.php current code:
get_header(); ?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
if ( have_posts() ) :
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
Further to this, the Featured Content is currently located at the top of the page and does not fit within the content and primary sidebars (it is positioned above the content sidebar to the right of the primary sidebar.
If you're worried about breaking a live site, then you should make a copy of what you've got, and install it locally on your machine.
WAMP is very good for this, if you're running Windows, and makes your computer act like an Apache web server.
Moving on from that, it would be helpful if you could provide some code, showing where your featured content slider is positioned.
And also make sure you're editing the correct file for your theme.
Related
I'm having quite a weird issue with my WordPress site. I am building a theme from scratch and I'm trying to make change to the containers on my blog page (page.php and single.php). Weirdly enough, I have made no major changes to the code other than add a wrapper, but the changes aren't showing up.
I've made many themes without this issue so I'm unsure what's going wrong this time. I have set the blog page to be the posts page in the settings so I can't understand why the template won't update. The code I have is below, and is just the standard WordPress code with the exception of 'grid wrapper' and attempting to remove the sidebar which also shows.
I have done quite a bit of research on this to see what the problem could be, but sadly the only post similar was in 2014 with no answer.
<div class="container main-content">
<div class="grid wrapper">
<section class="the-content">
<main>
<h1><?php the_title(); ?></h1>
<?php while ( have_posts() ): the_post(); ?>
<?php get_template_part('template-parts/content', 'page'); ?>
<?php endwhile; // End of the loop. ?>
</main>
</section>
</div>
</div>
Long story short, my content shows just fine. I just can't edit the wrapper which contains that content.
I would change parameters in get_template_part()
This is how it supposed to be used: Understanding get_template_part
So if you have blank Wordpress file structure, I'm not sure if you have template-parts for sure. You can have them only if you intentionally made them.
Use wordpress Wp-Super_cache Plugin
I had the same issue. Most likely index.php is overriding your file as in my case. It depends how your theme handles the loop so check out on your index.php and change it there.
If i remember well, the blog page set in the back-office reference first at home.php and then index.php. Page and single aren't call.
So, i finally got my css and js scripts to load on WP
Now there is but one thing i need to get done.
i have my own theme, including header.php, footer.php, page.php
header.php and footer.php is working just fine, loading scripts and showing properly, but now i need to add all the other content.
my page.php is currently:
<?php /* Template Name: CustomPageT1 */ ?>
<?php get_header(); ?>
<?php the_content(); ?>
<?php get_footer(); ?>
I would need to somehow add html content to pages, i have about 20 ready made .php pages which needs to be transfered to WP.
Soooo how do i go about making new page (pages -> add new) and using page template while getting the html content to show up?
I've tried to just make new page and in text mode add up all the html into page, but it only shows empty page with header and footer, so the problem is most likely the page.php and i have no idea how to get it to work.
You can do look like this:
<?php /* Template Name: CustomPageT1 */ ?>
<?php get_header(); ?>
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
<?php get_footer(); ?>
You are on the good way. While developing a custom theme from scratch is a great challenge it's not too hard.
I could recommend to take it easy and follow this tutorial I found really helpful some time ago, I learned a lot there:
Developing a WordPress Theme from Scratch
You must have the official source documentation always in your mind:
Theme Development
Do some reading and you will see that making themes is really fun and gratifying :)
EDIT:
I would recommend picking a good starter theme or framework and work using child themes. You have plenty of them to pick.
To get started adding a new page to your WordPress site, find the Pages menu in the WordPress Dashboard Navigation menu. Click Add new.
The WordPress page editor looks nearly identical to the post editor, except for a few different boxes located on the right side of the screen.
Add the title of the page, like About. Note: If you have pretty permalinks set up, the title of your page will also be the URL slug.
Next, add some content.
The Publish section of the page editor is exactly the same as for writing posts. When you’re ready to publish, you can either publish immediately, save this or a draft, or schedule the page to be published later.
The Page Attributes section applies a parent page and template to your new page. For the Parent section, you can arrange your pages into hierarchies. For example, you could create this new page with additional pages under it. There are no limits to how many levels you can nest pages.
Some WordPress themes have custom page templates, so the next Template section allows you to apply a template to your new page.
The Order box allows you to order your page numerically. Pages are usually ordered alphabetically, but you can choose your own order by entering a number in this field.
Preview the page one last time, then click Publish. You’ve added a new page to your WordPress site.
This is how your
your index.php should look like :
<?php
get_header();?>
<div class="YourContainer">
<div class="Whatever">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="ContentSectionDiv">
<?php the_content();?>
</div>
<?php endwhile; ?>
<?php else: ?>
<?php endif; ?>
</div>
</div>
<?php get_footer();?>
you can make also a custom loop
<?php
$arg = array("post_type" => "services",
"posts_per_page" => 9,
"order_by" => "date",
"order" => "ASC",
);
$services = new WP_Query($arg);
if ($services->have_posts()):;
while ($services->have_posts()):$services->the_post();
the_content();
endwhile;
endif;
?>
I m building a word press site with a unique theme that i created, now i got like 10 classes of different styles for the static pages in my site.
The question is, when i want to display the content of the page, with all the forms images and text, how should i do that? With the text editor where the user usually insert his content for the posts in regular wp website? Or should i insert the content images and forms hard coded in the php custom page template of those static pages?
In the text editor if i insert some html in edit as html it's becoming a mess it doesn't seems right to create sections and div where the user regularly just put his raw content, and anyway adding more content to a static page in the future will require my intervention to wrap it with css sections and div's definitions and classes...
By the other hand to write raw data with images and forms in the php custom page template doesn't seems to me the right choice... Is it normal to do so for static pages?
Thanks everyone!
Wordpress static pages, by default contains text and images that you can put into it using the Wordpress text editor. This content is known as "The Content" in WP context.
If you want to put into your static page some elements that cannot be setted by the text editor (like your own forms, per example) you'll need to create your own page template with hard-coded elements.
Example:
<?php /* Template Name: My custom page template */ ?>
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="article">
<div class="date"></div>
<!-- Your own custom content here -->
</div>
<div class="clear">
<?php if ( comments_open() ) : ?><div id="comments"><?php comments_template('', true); ?> </div>
</div><?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>
I normally will put those styles into styles.css of your theme. Even if it's images that will be standard images for the theme or shortcodes available to the user you want it to load from within the styles.css page. You don't want to do anything static like that with WordPress. Updates can mess it up as well as having issues with inline css messing up your SEO for the site.
If the user needs to do something in the editor to have an image show or something like that you can do it as a shortcode. That's normally going to be your best approach. Have you used shortcodes and loaded the images that before?
I am new to wordpress and following is my scenario.
I am inserting an external php script in wordpress by creating a new template in the theme and then using that template in a new page.
When I do this the new content is visible in the loaded page (and works as expected) but the theme breaks for the page i.e. all side bars (right and bottom) get lost. and if i am logged in the wpadmin bar at top is lost for that page only.
for all other pages everything comes back.
Could you guys please help me what could be going wrong here.
I doubt that there is some folder config going wrong somewhere.
Following is what I am doing:
inside my new theme page template -
<?php
/**
* The template for displaying pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
* Template Name: abctemplate
* #package WordPress
* #subpackage Twenty_Sixteen
* #since Twenty Sixteen 1.0
*/
?>
<?php
get_header();
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'template-parts/content', 'page' );
include_once dirname(ABSPATH) . '\abc\index.php'; // <=== the EXTERNAL SCRIPT
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
// End of the loop.
endwhile;
echo "end post loop";
?>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
</div><!-- .content-area -->
<?php echo "get_sidebar"; get_sidebar(); ?>
<?php echo "get_footer"; get_footer(); ?>
The above script internally after setting some variables, calls following template:
require_once('templates/'.$template.'/index.php');
the above template is a simple html page calling some variables in above abc/index.php
calling this breaks the wordpress theme mostly, the sidebars, (i am not sure yet if it breaks something else).
Could this mean that wordpress did not find the required side bar related files? but everything is inside the theme template.
Basically this whole thing is a scenario of loading an existing webpage into wordpress. I have the functionality working but UI breaks.
The problem I see first is naming the templates.
you have the following, which will throw a PHP parse error:
<?php
Template Name: abctemplate
?>
Have a look at the documentation here: https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/
A template name should be in a docblock as follows
<?php
/**
* Template Name: Full Width Page
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
Guess what ! it was the die() which was breaking everything. And the way I found it was totally lame(removing approx 2000 lines of code one by one). Anyways the reason makes a bit sense to me now. Thanks!
I'm trying to customize the archive-product page, and it works perfectly while I'm on my local server, but when I move it online, it's switches back to the default template. I'm trying to fix this for a week now, I've read all the other answers regarding this issue, but most of them are for an older version of woocommerce or the solution just doesn't work.
As a last refugee from madness, I've deleted all the archive-product.php file I can find, even the one in the woocommerce source folder, but nothing changed, I don't know where the site is getting the template from. The page have become self aware and I am going crazy because I have no idea what to do next.
Here is the difference between the page on local and online server
Please check if you have this in your functions.php, if not add:
add_theme_support( 'woocommerce' );
In theme root folder, add the file woocommerce.php and in that file set your own layout. For example:
<div class="wrapper">
<div class="sidebar">
// sidebar
</div>
<div class="inner">
<?php if ( have_posts() ) :
while(have_posts()) : the_post();
<?php woocommerce_content(); ?>
<?php
endwhile;
endif;?>
</div>
</div>
For more details: go through https://docs.woothemes.com/document/third-party-custom-theme-compatibility/