I'm using the YARPP plugin for a custom hosted wordpress site. I've changed the default location settings so that it only displays the widget where I specify (see screenshot). When I call the plugin in my single.php file it is moving the widget inside of the article.post, even when I try and contain it in a separate wrapping div.
single.php:
<article class='post'>...</article>
<div class='yarpp-wrapper'>
<?php if (function_exists('related_posts') ) : related_posts(); endif; ?>
</div>
output:
<article class='post'>...</article>
<div class='yarpp-related'>...</div> <!-- yarpp plugin-->
<div class='yarpp-wrapper></div> <!-- empty wrapper -->
I believe it's because you are using a custom yarpp template. Select 'List' instead, leave the other options above unchecked, and make sure the php script is in your single.php file. No need to wrap it in anything. Just place wherever you want it to show.
<?php related_posts(); ?>
Related
I am developing a custom theme in WordPress, and am trying to put custom HTML and PHP in my home page template. Whenever I am posting code for divs or custom fields in my home page template, they are simply not rendering and displaying on the front end. In the example below, the <div class="col-full"> is not being shown on the front end.
<?php
/*
Template Name: home
*/
?>
<!DOCTYPE html>
<?php get_header(); ?>
<center>
<div class="col-full">
<?php get_template_part( 'content', get_post_format() ); ?>
</center>
<?php get_footer(); ?>
Looking at your code, you've set it up as a template file. These need to be manually selected from the page as the template for it to work.
I'd recommend consulting the wordpress template hierarchy https://wphierarchy.com/. This shows you which files will try to be loaded based on what page you're visiting.
If you're still having trouble, i'd suggest installing the plugin https://en-au.wordpress.org/plugins/query-monitor/, which will tell you the template being loaded as well as other handy information.
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.
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?
There seems to be a problem with something on my wordpress page as a widget isn't displaying but I'm not sure how to edit the widget.
The code on homepage.php under Appearance>Editor is
<section class="row post_content">
<div class="col-sm-8">
<?php the_content(); ?>
</div>
<?php get_sidebar('sidebar2'); // sidebar 2 ?>
</section> <!-- end article header -->
Where would I find the code for 'sidebar2' as at the moment an error message appears on the page where the sidebar should display
As outlined in the Developer handbook for get_sidebar(), your sidebar file should be called sidebar-sidebar2.php. This file will be present in the root directory of your active theme.
The get_sidebar() hook allows a specific sidebar template file to be used in place of the default sidebar template file. If your file is called sidebar-new.php, you would specify the filename in the hook as get_sidebar( 'new' ).
I wish to add a custom page to wordpress, not in the usual sort of way. This page has my own custom script and functions and to develop a plugin is beyond my means so I was wondering if this is possible:
Suppose I were to build it on the existing page.php script in my there folder, my script looks something like this:
<?php get_header(); ?>
<div id="left-area" class="clearfix">
<?php
//My script would go here
?>
<div class="comments">
<?php comments_template('',true); ?>
</div><!-- end of comments div -->
</div><!-- end of left-area -->
<!-- LEFT AREA ENDS HERE -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Is this even possible? I tried and got a page not found error. And if so, how do I call this script assuming WP is installed in the root directory? Example: www.mysite.com/myscript
Absolutely. Duplicate page.php. Rename it to template_mine.php. Open to edit, and before the get_header tag, add:
<?php
//
// Template Name: My Custom template (choose something more descriptive, like contact page)
//
?>
Go to Wordpress dashboard for pages, create a new page with your title, and in the Page attributes on the right hand side, under templates, select your template name, update, and you are all set.
Reference: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates