How to include a html code inside wordpress index.php page - wordpress

I need to implement html code inside a wordpress index.php page.How to do this?
index.php-Wordpress template
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* #package WordPress
* #subpackage Wp_Bootstrap
* #since Wp Bootstrap 1.0
*/
// Gets header.php
get_header();
get_footer();
?>
Html
<div class="container">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>

It is pretty easy.
// Gets header.php
get_header();
//Start of code as part of answer
?>
<div class="container">
<p>Your text here</p>
</div>
<?php
//end of code as part of answer
get_footer();

Related

WordPress - Excluding div container from next pagination page

I have such a text container. He would like it to appear only on the first page of the blog's pagination.
<div class="column mcb-column mcb-item-c0belar2g one column_visual">
<h2>Title</h2>
<p>Lorem Ipsum Dolor</p>
</div>
I have a text container generated by Muffin Page Builder in WordPress. He would like it to appear only on the first page of the blog's pagination. I tried to create a code like this:
if (1 == $ paged) {
your container code
}
Unfortunately it doesn't work and I don't know if I need to create a function to hide this container on the following pages of pagination?
Here is a link to this blog page
I am trying to find information on the Internet, but so far I have not been able to find anything about it. Please help.
Image of this container

How open Wordpress posts in fancy box?

How I can open Wordpress posts in fancy box?
Eg:
Lorem ipsum LINK lorem ipsum.
When I click on LINK - how to open some post in fancybox or other "popup" like Litghbox etc.
You can simply use the thickbox js provided by wordpress for creating fancybox as like :
<?php add_thickbox(); ?>
<div id="my-content-id" style="display:none;">
<p>
This is my hidden content! It will appear in ThickBox when the link is clicked.
</p>
</div>
View my inline content!
For more details, check out here : https://codex.wordpress.org/Javascript_Reference/ThickBox
Edit:
For loading content from another source or site.
<?php add_thickbox(); ?>
View the WordPress Codex!

Wordpress gallery post doesn't work

I've been working on adding a gallery post on my blog, but whenever I add gallery it doesn't show the gallery itself. Instead it shows gallery shortcode on my post. Like this: [gallery ids="351,350"]. Is there any way to fix it?
Thank you!
It looks like you're trying to display galleries through the_excerpt(), but that's not supported by default.
Idea 1:
You could try to add this to your functions.php file in the active theme's directory:
add_filter( 'the_excerpt', 'do_shortcode' );
But you should be careful with that setup, because the excerpt can cut through the shortcode:
Lorem Ipsum ... [gallery ids=" [...]
if the excerpt text field is empty and it's automatically generated from the content text field.
So you should consider using the excerpt text field in that case.
Idea 2:
If you use the_content() instead, then you can use for example the <!--more--> quicktag in the post content:
Lorem Ipsum ...
[gallery ids="351,350"]
...
<!--more-->
...
to control the excerpt part. But the downside is that you would have to do it for all your posts ;-)

Extract certain section of posts as an excerpt in WordPress

I have a WordPress website, in which I have created multiple posts and bound them to a certain category.
Each posts has 6 paragraphs.
Here is what I am trying to achieve:
I have created a child wordpress theme file, in which I am retrieving all the posts from a particular category.
I want to display the 3rd paragraph from each posts ( upto 40 words ) as an excerpt.
Anyone can help me to achieve this?
Any help will be appreciated...
Thank You
Edited:
Contents of one of the posts:
<div id="grey">
<div id="title">
<h1 id="divtest">Title</h1>
</div>
<div id="divContentText1"><span class="button5_hover"></span><strong>Back To Test Page</strong></div>
</div>
<div class="wrap" id="divPgInfo">
<div id="divInnerImgSliderWrap">[meteor_slideshow slideshow="test"]</div>
<div id="divImgTxtWrap">
<h4 class="innerSlideHd">Test Title</h4>
<p class="innerSlideText">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.</p>
<p class="innerSlideText">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
<p class="innerSlideText">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
<p class="innerSlideText">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
<p class="innerSlideText">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>
<div class="divClr"></div>
</div>
<div class="divClr"></div>
Now I want to show the contents from the sentence "It is a long established...."
Any help will be appreciated....
Really Thank you...
In You Post Editor screen at wordpress backed
Write your 3rd paragraph in "excerpt" text area. (Enable it from top of edit screen page)
For display this content in fronend use the_excerpt function.
Inspired by this question and by the fact that Wordpress' excerpt is often not flexible enough for user needs, I jotted down a function allowing to use any HTML tag inside the post content as this arbitrary post excerpt.
Mind that the function can get some work to improve flexibility, for example you could substitute the excerpt with this custom excerpt altogether, or perhaps implement some other parameter to allow a more in-depth searching (something like marking the excerpt paragraph with an id="excerpt").
I went for a specific solution to your problem, however, and elaborated a bit more to allow some flexibility. You can put this code in your functions.php:
/*
* Defines an arbitrary excerpt by using any post content HTML element
*
* The function accepts an optional array of arguments.
* Optional $args contents:
*
* * id - The id of the post we want the excerpt of. Defaults to the current post.
* * tag - The HTML tag we want to use as an excerpt.
* * idx - The index of that tag as calculated considering the post_content as the root.
*
* #param array|string $args See above description.
*/
function my_get_the_excerpt($args = array()) {
$defaults = array(
'id' => null,
'tag' => 'p',
'idx' => 0
);
$args = wp_parse_args($args, $defaults);
$args = (object) $args;
$post = get_post($args->id);
if ( post_password_required($post) ) {
return __( 'There is no excerpt because this is a protected post.' );
}
$post_content = '<html>' . apply_filters('the_content', $post->post_content) . '</html>';
$post_html = new DOMDocument();
$post_html->loadHTML($post_content);
$paragraphs = $post_html->getElementsByTagName($args->tag);
return $post_html->saveHTML($paragraphs->item($index));
}
After doing that, in your case you could solve your problem by simply using this function in your template, instead of the_excerpt. Like so:
// This gets the third paragraph of your post.
echo my_get_the_excerpt( array( 'idx' => 2 ) )
Put a specific ID on the tag of the paragraph you want to use as an excerpt and when you want to use the excerpt just parse the content of the article and extract only the part in your with the id you've determined.
check this : Get content within a html tag using php and replace it after processing

">" character when import post from blogger to wordpress

When I import the posts from my blogger account, I get all of posts have ">" character at first.
So example my correct post :
Lorem Ipsum Dolor
This is the post content. Lorem Ipsum Dolor Sit Amet
But, at import result it gets like this :
>Lorem Ipsum Dolor
>
This is the post content. Lorem Ipsum Dolor Sit Amet
I've try with all of my blogs in my blogger account.
I use WP 3.2.1
This was mentioned on the Wordpress.org forums: http://wordpress.org/support/topic/extra-character-on-blogger-import
With a link to this site: http://core.trac.wordpress.org/ticket/13458

Resources