Disable WordPress auto paragraph - wordpress

I've been trying to remove the wp auto p. I've tried both remove_filter('the_content', 'wpautop'); inside my theme's functions.php file and any plugin available to do this, but none of them are actually working.
Also i am not using any plugin that could be placing these p tags, so I am very confused.
Any help would be appreciated.

<?php
/*
Template Name: Text template.
*/
get_header(); ?>
<?php
if(have_posts()):
while(have_posts()): the_post(); ?>
<div class="color-1">
<div class="content">
<p><?php the_content(); ?></p>
</div>
</div>
<?php endwhile;
endif;
?>
<?php get_footer(); ?>
The paragraph around <?php the_content(); ?> was the reason why.

Related

Wordpress page.php not working it's defaulting to index.php

So, I am doing a tutorial but, every time I go into the wp admin and View one of my pages.It doesn't pull my page.php but, my index.php. I am not sure how to fix this or what I am doing wrong.
<?php get_header();
while(have_posts()) {the_post(); ?>
<h1>This is a page not a post</h1>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php }
get_footer();
?> ```
<?php get_header();
while(have_posts()) {
the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<hr>
<?php }
get_footer();
?>```

How to show posts in custom page template in wordpress?

I am trying to make my custom page template,in which i display post with custom styles, i don't know how to show posts in this custom page template,here i am attaching my simple code for custom page template.
<?php
/*
Template Name: Custom Template
*/
get_header();
//custom code for post is here
get_footer();
?>
You can use WP_Query() to add a custom loop to your page template. You can find a few examples in the WordPress Codex
You can always use page template similar to this and make full use of the codes over here writing with our own classes and style you are referring to :
<?php
/*
Template Name: Custom Template
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<header class="entry-header">
<?php the_post_thumbnail(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

How to print text from db in special template for specific page in wordpress

I have five pages and I have created a different layout for last two pages, that layout has a div with class infoDiv and that div has a text which I just put manually in the source code, so I can't change it through wordpress. How can I have it available in my dashboard so client no need to change in code?
<?php
/*
Template Name: Special Layout
*/
get_header();
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<article class="borderClass">
<h2> <?php the_title(); ?> </h2>
<div class="infoDiv">
<h4>This is info div</h4>
<p>this is the text I want to edit or add
using dashboard.</p>
</div>
<?php the_content(); ?>
</article>
<?php
}
} else {
echo "<p>No content found</p>";
}
get_footer();
Just move <?php the_content(); ?> like below
<article class="borderClass">
<?php the_title( '<h2>', '</h2>' ); ?>
<div class="infoDiv">
<?php the_content(); ?> <!-- Entered content -->
</div>
</article>

Wordpress Placing of the_content() function in custom page

I have made a custom page in my wordpress theme. The page is working fine. But I am facing trouble using the_content(); function. I am using a few custom fields to display some content on the page and I want the content of the page, that is entered in the Editor, to be displayed on a specific place on the page. But Whatever I enter in the Editor, gets placed at the top of the page above all other content.
EDIT:
Here is the full code:
<?php get_header(); ?>
<div id="main-content">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
<div class="mobile-top">
<a href="<?php the_permalink(); ?>">
<p><?php the_title(); ?> price</p>
</a>
</div>
<?php comments_template(); ?>
</div>
</div> <!--main-content Ends-->

Custom Wordpress Post Page Breaks if More Than 2 Posts?

I have a very custom template, and it works great if there are 1 or 2 posts on the blog page. But as soon as a 3rd post is added, it alters the structure of the template... Literally moves a div inside of another and I cannot understand why. The code for the blog template is here, and a screenshot of the structure as it should be and another showing the misplaced div when a third post is there. Does this make any sense, any ideas?
<div class="post" id="post-<?php the_ID(); ?>"><!--start post-->
<h2><?php the_title(); ?></h2>
<div id="main_full" class=" clearfix"><!--start main-->
<div id="top_bar"><h3 class="gallery-title">news</h3></div>
<div id="blog_page"><!--start blog page-->
<div class="entry"><!--start entry-->
<?php the_content(); ?>
</div><!--end entry-->
</div><!--end blog page-->
</div><!--end main-->
<?php endwhile; endif; ?>
</div><!--end post-->
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
<?php comments_template(); ?>
Without seeing the beginning of your loop, I can't be 100% sure, but it looks like you need to have:
<?php endwhile; endif; ?>
</div><!--end post-->
be
</div><!--end post-->
<?php endwhile; endif; ?>
<?php endwhile; endif; ?>
</div><!--end post-->
Flip their places. If it doesn't help, please show us what while and what if are getting closed.

Resources