I am using wordpress 3.6 and advanced custom field plugin 4.2.1.
advanced custom field settings - https://dl.dropboxusercontent.com/u/15109395/q/acf-media.png
my post - https://dl.dropboxusercontent.com/u/15109395/q/page-content.png
my single page code
<section id="contentLeft" class="single">
<?php if ( have_posts() ) { the_post(); the_content(); }?>
</section>
Result - https://dl.dropboxusercontent.com/u/15109395/q/page-front.png
but , i don't want that attachment image on content area. my local installation have no problem. not showing attachments. but my live website showing attachment uploaded to that post.
how can i solve this issue? please help me. Thanks.
My problem solved with this solution. Thanks.
http://wordpress.org/support/topic/thumbnails-magically-appearing-on-all-pages
if you want remove images from all posts and pages, simple copy the following code into your theme functions.php
<?php
function remove_images( $content ) {
$postOutput = preg_replace('/<img[^>]+./','', $content);
return $postOutput;
}
add_filter( 'the_content', 'remove_images', 100 );
?>
it will remove the images wherever the_content() have images
else you need to include this function in specific page , put the following code
<?php remove_filter( 'the_content', 'remove_images' ); ?>
Related
Am using The7 Theme. Since I wanted to create a NEWS section to post latest news (apart from the Blog, which is separate), I used the Custom Post Type UI plugin to create a custom post type named news
I created a new file in my child theme, by copying the contents of the parent theme's archive.php file and named it as archive-news.php, with a minor modification:
<?php
/**
* Archive pages.
*
* #since 1.0.0
*
* #package The7\Templates
*/
defined( 'ABSPATH' ) || exit;
$config = presscore_config();
$config->set( 'template', 'archive' );
$config->set( 'layout', 'masonry' );
$config->set( 'template.layout.type', 'masonry' );
get_header();
?>
<!-- Content -->
<div id="content" class="content" role="main">
<div class="news_years text-center">
<?php for( $i = date('Y'); $i >= 2009; $i-- ) { ?>
<?php echo $i; ?>
<?php } ?>
</div>
<?php
//the_archive_description( '<div class="taxonomy-description">', '</div>' );
if ( have_posts() ) {
the7_archive_loop();
} else {
get_template_part( 'no-results', 'search' );
}
?>
</div><!-- #content -->
<?php do_action( 'presscore_after_content' ); ?>
<?php get_footer(); ?>
So the modification done was that I commented out the description that would be shown at the top of the page, and added year buttons.
After this, when the www.mysite.com/news was accessed, it pretty well loaded all my news items and when clicking an item, it loaded the detailed page as well. And the pagination also works very well, as it inherits the parents theme's template files.
The problem am facing is, I want to make it display year wise items also. Say for example, right now, when accessing the www.mysite.com/news url, it loads up all the News items with pagination. I want to filter it based on a particular year. That's why I included the additional FOR loop in the above code.
Upon searching, I found that the WP Query has date parameters that can be used which will resolve my issue.
But am not sure how to apply this as this archive page is already doing the fetching of posts. And also, how to pass the year in the URL as well. Any pointers would be highly appreciated.
If this is not the right forum to ask this question, please feel free to move this thread to the apt forum. Thank you.
How to display author name near the date on my website homepage and single post page? . Is there is css code for that. Iam using hemingway theme. And my website is www.avjtrickz.com . please help me, Thanks for advance.
You have to use:
<?php $author = get_the_author(); ?>
or:
<?php the_author(); ?>
Here you can find more information: https://codex.wordpress.org/Function_Reference/get_the_author
And here: https://codex.wordpress.org/Function_Reference/the_author
And here: Show Author name in single.php (Wordpress)
This needs to be done using the WordPress codex for author. This reference needs to be used in the Loop. There is no CSS for this.
https://codex.wordpress.org/Function_Reference/the_author
<?php $name = get_the_author_meta( 'display_name' ); ?>
reference : https://developer.wordpress.org/reference/functions/get_the_author_meta/
Is there a way to get a thumbnail from any website link? For example, if I take a link from imgur and post it on my website in the post itself, it shows the image. But when I go to the homepage of my website there is no featured image for that post. Just a great box. How could I generate a featured image of any link I posted from an external website?
I have used the video thumbnail plugin but it only works with certain websites.
try going into page.php of your theme, then search for the_post_thmbnail(). There add the image link
change this line:
<?php the_post_thumbnail(); ?>
to something like this:
<?php $name = get_post_meta($post->ID, 'ExternalUrl', true);
if( $name ) { ?>
<?php the_post_thumbnail(); ?>
<?php } else {
the_post_thumbnail();
} ?>
hope this helps :)
I'm creating a custom post type for creating gallery posts. One of the things I took out was the 'editor' section since I have my own uploader. Since the HTML editor is gone (can't use shortcodes now), is there a wp function which is the equivalent of the [gallery] shortcode?
As per the Codex recommendation for outputting the [gallery] shortcode content directly in a template file, I would use do_shortcode():
<?php do_shortcode( '[gallery]' ); ?>
You can even pass accepted parameters:
<?php do_shortcode( '[gallery columns="4" size="medium"]' ); ?>
Got it. Here's the code for anyone else who wants to do the same thing. Throw this baby in your theme template file and try it out.
$images = get_children(array('post_parent'=>$post->ID, 'post_type'=>'attachment', 'post_mime_type' => 'image'));
foreach($images as $image){
echo wp_get_attachment_link($image->ID);
}
You can use the wordpress function make for this purpose
gallery_shortcode(array('orderby'=>ID));
by sure to call this after you setup the post
I know this may be a simple question but I am a total beginner at Wordpress coding and PHP. I am looking to embed five attachments to each post on my site, so I know it has got to do with inserting something into single.php or loop.php. So let's say I have 8 or 10 photos attached to a post, I want the single post page to show 5 of those photos and have a link to the 'gallery'/attachment.php page. Something like what this website does on this page, the 6 photos at the end of the post entry (http://www.celebuzz.com/2011-05-27/kim-kardashian-kris-humphries-makes-first-post-engagement-public-appearance-photos/)
I have tried using the wordpress [gallery] insert but all it does is show all the pictures and I don't want to use a plugin because I feel that it is overkill and all it needs is some code to call up 5 attached photos. Hope someone can help. Thanks in advance
Try using custom field template plugin
http://wordpress.org/extend/plugins/custom-field-template/
I know you don't want to use plugin. But, for the sake of the questions and I know someone will eventually landed here from search engine.
You can use attachment plugin. This plugin is quite simple and very straightforward.
Once installed, it will add new meta box on post creation page.
You can add as much as images you like and the loop part of your template page, you add this snippet:
<?php
if( function_exists( 'attachments_get_attachments' ) )
{
$attachments = attachments_get_attachments();
$total_attachments = count( $attachments ) > 5 : 5 : count( $attachments );
if( $total_attachments ) : ?>
<ul>
<?php for( $i=0; $i<$total_attachments; $i++ ) : ?>
<li><img src="<?php echo $attachments[$i]['location']; ?>" alt="<?php echo $attachments[$i]['title']; ?>" /></li>
<?php endfor; ?>
</ul>
<?php endif; ?>
<?php } ?>