Remove Thumbnail Inside Posts - Wordpress - css

I am trying to hide the blog post thumbnails inside the blogposts, but at the same time I want to keep the thumbnails in my blog overview.
So far, I used the following CSS to make the thumbnail images disappear:
.attachment-post-thumbnail {display:none;}
However, this also makes them disappear on my blog overview: www.wavebutler.surf/surf-blog
Could anybody help me and let me know what CSS I could use to make the thumbnails disappear inside the posts. It would be very much appreciated!

Not sure if you found your solution or not but, Depending on your themes structure, in single.php look for something like
if(has_post_thumbnail()) :
the_post_thumbnail();
endif;
If you remove it from single.php or comment it out your single posts will no longer have your featured images
This could also be located in content.php which in this case you can just put a conditional statement on it.
if(!is_single()) :
if(has_post_thumbnail()) :
the_post_thumbnail();
endif;
else :
// continue on
endif;
Probably won't be this general as again it will depend on your theme but in a nut shell is how it can be done.

Related

How to add custom content in sidebar of each Wordpress post?

I want to integrate specific text (text, links, images) making reference to specific sentences of my blog post.
Is it possible to do it with code or using a plugin ?
I send you a sketch :
This is the sketch
That is common need and often Aside in WordPress is talked for it. There are WP plugins like Aside Widget, Custom Sidebars for ordinary needs. But if you need too much custom stuff like my website's "About this Article" sidebar widget - https://thecustomizewindows.com/2016/09/limitations-of-openvz-virtualization-to-guest-cloud-server-vps/ then it is better to use
Otto's this plugin to use PHP in text widget - https://wordpress.org/plugins/php-code-widget/ and use PHP. In my case, rest is PHP code like this on sidebar (I can use shortcode too) :
<?php if(is_single()) : ?>
<h3>About This Article</h3>
<strong>Title:</strong> <?php echo get_the_title(); ?><br />
Published on: <?php the_time('Y-m-d') ?>
<br />
...
// rest of the code
<?php endif; ?>
Obviously you can call post image thumbnail with WordPress function.
As you need specific text, you may think about combining Pull Quote Plugin or Aside Widget to mark the specific like and echo it with PHP.
As other options -- you can use CSS3 to automatically select first line, first paragraph, second sentence. You can use Javascript to conditionally mark.
Best possible customisation I saw is on BMJ's sidebars. They use Drupal, not WordPress. BMJ has beautiful sidebar -- (as example) - http://www.bmj.com/content/355/bmj.i4924 Drupal has description of the work - https://www.drupal.org/node/1557636 Sadly I lack idea about Drupal. I tried a lot behind using WordPress for academic purpose.

how to assign image dynamically in wordpress post

I am developing one wordpress site. I have made one post in it. Now I want to assign image in that post. For this, I have uploaded one image in media and attach that image to my post.
but how can I assign that uploaded image in my post? do I need to give path manually? or I can give dynamic path so that even if I upload this site on server or change main folder name, path gets changed automatically..
any help will be appreciated..
thank you
You should consider using Post Thumbnails (also known as Featured Images) in your posts. To do this, all you need to do is add the following to your functions.php file:
add_theme_support('post-thumbnails');
This will add a control in your Post Editor to add an image by either Uploading it or setting the URL, effectively "attaching" your image to your post in the way your looking for. To display the image in your template:
<?php
if(have_posts()) : while(have_posts()) : the_post();
if(has_post_thumbnail())
echo '<div class="post_thumb">'.get_the_post_thumbnail().'</div>';
?>
<div class="post_content"><?php the_content(); ?></div>
<?php
endwhile;endif;
?>
As for changing folder names, paths, etc. you need to be careful with that approach. Remember that you're giving a path to an asset. The server doesn't know what YOU want, only what your code is requesting. If you expect to be changing paths to your assets around quite a bit, then you can always forgo Post Thumbnails in favor of clever naming conventions. Something like this:
<?php
if(have_posts()) : while(have_posts()) : the_post();
$imgPath = get_bloginfo('stylesheet_directory').'/images/featured_'.$post->post_name.'.jpg';
?>
<div class="post_thumb"><img src="<?php echo $imgPath; ?>" /></div>
<div class="post_content"><?php the_content(); ?></div>
<?php
endwhile;endif;
?>
This looks for an image in your Theme Directory's images folder that is named featured_{post_slug}.jpg
The benefits to this approach is that Wordpress will always know where your theme folder is, regardless of URL changes. As long as you have an images folder in your theme directory, Wordpress will know where to look.
The drawback is that this code specifically doesn't first check for the EXISTENCE of the image before displaying it, which could lead to broken images if they aren't named properly or don't exist at all. This approach also requires the use of one file extension
A last option for you is to consider using Custom Fields to define paths to images. The benefit is that this does not require you to actually upload images to your server. However, this approach is still the least dynamic out of all of your options, and will likely break if paths to assets are changed.
Use whichever tool you feel is best for the job. Hope this helps!

wordpress <!--more--> not rendering a link

I am using the <!--more--> tag in my wordpress copy to create an excerpt from the main content and also echo a link, however it is totally disregarding this tag and just posting the full article, below is hope I am implementing it in my templates,
<?php the_content("Read more about this article..."); ?> am I doing something wrong? Currently it is showing the while post when I use the above code, however it is my belief that it should only only show everything above the <!--more--> tag?
As per the official WordPress support site:
From the use of your PHP code, it looks like you want to use the more tag on pages. More works with blog posts but not pages. Please add the following code to your document above your PHP line you provided to make it work:
<?php
global $more;
$more = 0;
?>
Also, be sure that you are not simply in preview mode and that you have actually published the article and previewed it:
[T]he more tag is not displayed in post previews, since previews display
posts in entirety, but the more tag will appear once the post has been
published.
Perhaps you are using custom page template to display archives. "More" tag doesn't work in pages. If you want to turn it on in Pages...
<?php the_content("Read more about this article..."); ?>
you should use the code like this if you wanna show the to work in a page
<?php
global $more;
$more = 0;
the_content("Read more about this article...");
?>

How do I get the WordPress sidebar to show up on a post's detail page?

My example is here
I am customizing the default template, but something isn't placed right. Can't figure it out.
By the way, I am asking this here and not at WordPress because frankly, their forums are horrible as far as response times go. Stackoverflow has always done me good :)
Without seeing the php code it'll be hard to know why. Do you have a seprate template for single post ie singlepost.php? If so, make sure you're include sidebar.php into that.
Looks like single.php in the default theme doesn't pull in the sidebar by default. You'll need to add <?php get_sidebar(); ?> right before <?php get_footer(); ?> in single.php or just delete the single.php and wordpress will use index.php instead which has the sidebar.

Display Posts from a category in Wordpress?

I am trying to display just post title and their links within a set category. However I am running into issues understanding the Codex. Any help or guidance would be greatly appreciated.
I use this a lot in my blogs. Helpful when you want to display featured items or such.
http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters
http://codex.wordpress.org/The_Loop#Style_Posts_From_Some_Category_Differently
You might have seen the above link. I'll explain how it works.
Posts are loaded using the loop. If you do a Query Posts just before the loop, you can choose from select category (or many categories) and also limit the number.
<?php query_posts('cat=1&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><?php the_title(); ?>
<?php the_excerpt() ?>
</li>
<?php endwhile; endif; ?>
You can use the above code as many times you wish. Choose the category ID (can be found from the admin) and the number of posts you wish to show.
Comment - if you require additional help.
It seems that you are working on your templates. It basically means that you need to edit correct template and insert the right tags.
Firstly, you need to understand how the template is chosen. WP has special hierarchy for every view. Home page is usually home.php and categories are category.php or category-1.php. If any file is missing, WP simply takes next on the list. Last on the hierarchy list is index.php which is chosen if no other file is found.
[http://codex.wordpress.org/Template_Hierarchy#Category_display][1]
Secondly, look at the template tags. Displaying only title with link means you need title and permalink tag. Anything else is optional.

Resources