So I had the idea to create a div with the class 90. where the <?php the_title( '<h3>', '</h3>' ); ?> of the page is shown in a 90° angle.
Works great. Just some tweaking to get the layout working correctly.
I added in the reading settings the option that A static page is selected for my posts.
Now I want that the page titel is shown in the DIV 90 and not the post title. But apparently the <?php the_title ?> is for both of them.
Is there a way to determine what title you want selected? So in this case load/echo the page title and dismiss the post title.
Hope I explained it right.
You should do a search in the WordPress codex, has a lot of useful information there..
https://codex.wordpress.org/
This is what I believe you are after:
<h3><?php wp_title(); ?></h3>
https://developer.wordpress.org/reference/functions/wp_title/
Related
I'm having a strange problem. I created a custom home page template to pull the latest 5 posts from two different categories into the layout (see "Learn and "Play" columns).
http://sensoryrevolution.com.s177767.gridserver.com/
I'm pulling in 4 fields through a custom query I copied+pasted from this very site:
Post thumbnail
Permalink
Post title
Excerpt
Only the excerpt is wrong. It's displaying the excerpt from the blog post above it.
Here's the code I'm using to pull this in. The weird thing is that it was working, and now it's broken. I've backed out some other custom code I had that was limiting the number of characters in the excerpt, so this is purely the_excerpt() working its magic.
<?php $posts = get_posts('category=213&orderby=desc&numberposts=5'); foreach($posts as $post) { ?>
<h4><?php the_title(); ?></h4>
<?php the_post_thumbnail('blog-large'); ?>
<p><?php the_excerpt() ?><?php // echo excerpt(22) ?></p>
<?php } ?>
This is driving me crazy! Does anyone have any ideas?
The post excerpt takes the excerpt from the excerpt field in wordpress. By default the excerpt field is not shown on wordpress single posts/pages in the admin backend. You can add it by clicking the "screen options" in the top right of the "add new" post/page (or custom pages). You can then input any text you would like as the excerpt.
As you can see by your var_dump, it is saying there is no excerpt in the post:
" ["post_title"]=> string(14) "It Makes Sense" ["post_excerpt"]=> string(0).
As stated before, the_excerpt() does not look for the excerpt in the main content body. If you don't feel like adding the excerpt field in the back end, you can do something like this:
$content = get_the_content(); echo substr($content, 0, 20);
This will output the first 20 characters of the string (which is the content of the page/post/custom post). Obviously you can do 40 or something like that as well, to appropriately output what you feel is the rite amount.
Happy coding!
I am not really sure how to ask this question, however if you have a look at this link you will see what I mean
http://www.skirentalwhistler.com/skill-level/beginner
You will see that the shortcodes for a [box] are not being executed.
If you browse a single product, the shortcode works fine - eg click on the first product called 'Compact' and you will see the [box] is executed into the grey box with one grey and one orange button in it.
Also, I have spent a few hours now trying to work out which template is creating this page. The page is a listing of all products with a certain product attribute value (attribute is skill-level and value is beginner)
I expected it to be archive-product.php but it doesn't seem to be, and I can't find any other file dealing with multiple products on a single page
Any help is appreciated!
When you are using a shortcode in a post, then the [box] syntax is what to use. However, if you are doing a shortcode in a template, you must execute the shortcode with php. Since your homepage appears to just display the short code instead of running it, then it is probably in a template. To execute a shortcode in a template, do this
<?php echo do_shortcode('[box]'); ?>
so for the one on your home page
<?php echo do_shortcode('[box size="small" style="rounded" border="full"]'); ?>
Ok, I have worked out how to do it.
Big thanks to chiliNUT for their help, as they helped me to keep going and going.... thus I gave them an uptick
Anyway, it was using the themes archive.php template (not the woocommerce plugin templates as I presumed). In archive.php, I changed the following line in the div class 'entry'
<?php if ( $woo_options[ 'woo_post_content' ] == "content" ) the_content(__( 'Read More...', 'woothemes' )); else the_excerpt(); ?>
to
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
It now works and doesn't seem to have broken anything else.
I'm teaching myself Wordpress, and my current goal is to display 4 thumbnails of images posted in a particular category.
I've already got the posts being pulled in by category, however I cannot pull ONLY the images. It's either the images and post text, or none at all.
My code is posted here: http://pastebin.com/NZ7fyyPA
I've tried simply replacing
<?php the_content(); ?>
with:
<?php the_post_thumbnail(); ?>
but that didn't work at all. Nothing came back at all!
I've even tried simply removing:
<?php the_content(); ?>
and same as above! I was thinking that because I have
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
That would pull the thumbnail in only, so I thought removing the content would help but nope!
I've read through the Codex here: http://codex.wordpress.org/Function_Reference/the_post_thumbnail
and the only question I have from that, is that immediately the Codex says:
"Use get_the_post_thumbnail($id, $size, $attr ) instead to get the featured image for any post."
Which I don't think I'm doing, because I haven't setup anything related to a 'featured image' in my theme...or is what I'm trying to do considered using a featured image? I'm only uploading images and posting them inside of the blog posts.
Sorry for the long write up, I'm sure it's something simple!
Thanks!
One more thing you can set a featured image from admin and call that image with this code the_post_thumbnail( $size, $attr ); and when you want to show anything from content part then you can call with this code simply. the_content();
you can also use excerpt for this as the_excerpt();
Thanks
This is a bit of a hack; however, it works.
While viewing your Wordpress website, use the browsers developer tools to target the 'post text'. You'll be able to see the id that is associated with that data-set.
Then, in your CSS. Target that id and use display:none;
Example:
#posttext {
display:none;
}
I'm using a template called 'expression' for Wordpress which works fine.
I'd just like to tweak it a little.
I have a page that shows all my blog posts, and ofcourse each blog post has an own overview if you click on it.
on each blog post you make, you can set a featured image. This image is shown on the overview page, and on each individual detailed view of 1 blog post.
I'm trying to find a way to only show this featured image on the overview page of all blogs, and not on the detailed view of a blog post.
Is there a way to do this?
I tried to edit the code in post-template.php by adding:
ispage('blog')
full code:
if(has_post_thumbnail() && !$hide_thumbnail && !is_page('blog')){ ?>
<div class="blog-post-img">
<?php if(!is_single()){?>
<a href="<?php the_permalink(); ?>">
<?php }
$img_id=$pex_page->layout=='full'?'post_box_img_full':'post_box_img';
the_post_thumbnail($img_id);
if(!is_single()){
?>
</a>
<?php } ?>
</div>
<?php
}
this works, but both featured images will be gone. which is not what I wanted.
Thanks for your help!
Got it eventually,
you have to use:
is_single();
instead of :
is_page();
Thanks anyway.
So I am trying to add a "-none" to a class for a post if it is in a specific category in Wordpress. So like lets say if I am viewing a post that has a category id of 7, i want a certain class titled "example" change to "example-none".
Here's my code:
<div class="example<?= is_category('events') ?'-none':'' ?><?= in_category('7') ?'-none':'' ?>">
The weird thing with the code is, it works in a page when I am viewing all the posts in a specific category. But when I go to an interior post that is in a specific category, the code does not work.
I am using the in_category('7') tag to achieve this on a wordpress sidebar.
Any idea on what I am doing wrong?
I would remove the quotes around the id of the category:
in_category(7)
This should be a number, not a string.
Thanks. i got it working using this code:
<div class="example<? wp_reset_query(); ?><?= in_category(7) ?'-none':'' ?>">