Can you please let me know how I can add a class to an image getting from Post Content?
I have a page called promotion and it only contains an image which I uploaded through Add Media now in page I have
<div class="container">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
and at front end I am getting this:
<img class="size-full wp-image-2202 alignright" src="http://rumioptical.com/wp-content/uploads/2014/11/Promotion-Banner.jpg" alt="Promotion Banner" width="800" height="640">
but I need only to get
<img class="img-responsive" src="http://rumioptical.com/wp-content/uploads/2014/11/Promotion-Banner.jpg" alt="Promotion">
removing the size-full wp-image-2202 alignright classes and widtd and height attributes and adding the img-responsive?
Thanks
Edit the post using the text editor rather than the visual editor. Change the attributes in the HTML to match what you need:
<img class="img-responsive" src="http://rumioptical.com/wp-content/uploads/2014/11/Promotion-Banner.jpg" alt="Promotion">
Related
I am trying to only load the 4 latest posts on my page and I have found a line of code that should work. The problem is that I don't know where to put it.
<?php query_posts('posts_per_page=20'); ?>
This is what I found when I was searching for a solution (although I don't know if this will also work for showing only the 4 newest posts. As you can see I already have 'catname=projecten' on that line and I have no idea how to combine the two.
<?php
query_posts('catname=projecten');
while (have_posts()) : the_post();?>
<div class="col-md-3">
<div class="newsfeed center">
<h1><?php echo get_the_title( $ID ); ?> </h1>
<p>
<?php the_content(); ?>
</p>
</div>
</div>
<?php endwhile;
?>
I hope someone can help me out!
I'd like to answer it, because there are few things need to be corrected. This should do it, and notes below.
<?php
query_posts('category_name=projecten&posts_per_page=4');
while (have_posts()) : the_post(); ?>
<div class="col-md-3">
<div class="newsfeed center">
<h2><?php echo get_the_title(); ?> </h2>
<?php the_content(); ?>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
A few notes:
It's category_name, not catname.
You should not use <h1> for each title, for a better accessibility use <h2> or <h3> etc.
get_the_title( $ID ); the $ID seems not necessary to be there.
Don't wrap the_content(); with <p> it's rich content already, use <div> if you need.
Don't forget to reset the query afterwards.
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
http://codex.wordpress.org/Function_Reference/query_posts
http://codex.wordpress.org/Class_Reference/WP_Query
I created a custom content type, and a view for it.
My page.tpl.php has the following
<div class="<?php print (drupal_is_front_page()) ? 'frontBox' : 'container contBox'; ?>">
<div class="<?php print ($page['categories_blog'] || $page['recent_blog'] || $page['recent_comments']) ? 'globalContant span9' : 'gCont'; ?>">
<?php print render($page['content']); ?>
<?php if ($page['contact_info']): ?>
<div id="contactInfo">
<?php print render($page['contact_info']); ?>
</div>
<?php endif; ?>
</div>
so I have set up my custom content similar to other template objects and they do not get render with the page['content'] yet the one I created gets rendered.
Drupal being so obsfucated is frustrating the hell out of me
I'm using Wordpress Canyon Theme in my website (http://thomasconti.blog.br/). The slider works fine but it would be really great if it also showed post titles and in larger letters, instead of just a bunch of small text like the default configuration is set to show.
Please, if anyone can help, here is the code for the slider:
<?php get_header(); ?>
<div id="content">
<div id="slide">
<div class="flexslider">
<ul class="slides">
<?php
$slide = get_option('cany_slide_cat');
$count = get_option('cany_slide_count');
$slide_query = new WP_Query('category_name='.$slide.'&posts_per_page='.$count.'' );
while ( $slide_query->have_posts() ) : $slide_query->the_post();
$do_not_duplicate[] = $post->ID
?>
<li>
<img class="slideimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo get_image_url()?>&h=300&w=650&zc=1" title="" alt="" />
<div class="flex-caption">
<?php wpe_excerpt('wpe_excerptlength_slide', ''); ?>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
I tried to find this info on the web but only found other bloggers using this theme and asking the same question. Thanks in advance for any help.
I don't know that plugin but from your question I'd say you need to put a wordpress template tags for the title in here:
<div class="flex-caption">
<!-- at this place -->
<?php wpe_excerpt('wpe_excerptlength_slide', ''); ?>
</div>
E.g. mock that with some dummy HTML and headlien:
<div class="flex-caption">
<h2>This is My Headline that is Just There</h2>
<?php wpe_excerpt('wpe_excerptlength_slide', ''); ?>
</div>
Style it via your themes CSS and for the content use the_title():
<div class="flex-caption">
<?php the_title( '<h2>', '</h2>' ); ?>
<?php wpe_excerpt('wpe_excerptlength_slide', ''); ?>
</div>
Depending on your styling needs you might want to introduce more markup.
To link the title you use the_permalink() again as you already have in your code. That could do it, so hopefully this gives you some pointers.
I created my own author.php template. I want to display author's custom meta fields Code samples is in this image : http://prntscr.com/wsdsa
But Wordpress doesnt display anything ? What should i do ?
<div class="BCol">
<?php echo keepAuthorImage(); ?>
</div>
<div class="ACol">
<div class="A1"><?php echo get_the_author_meta('first_name') ?> <?php echo get_the_author_meta('last_name') ?></div>
<div class="A2"><?php echo the_author_meta('job') ?></div>
<div class="A3"><?php echo get_the_author_meta('location') ?></div>
<div class="A5">
<img src="<?php echo THEME; ?>/_assets/_img/websiteicon.png" alt="">
<img src="<?php echo THEME; ?>/_assets/_img/twitteric.png" alt="">
<img src="<?php echo THEME; ?>/_assets/_img/instagramic.png" alt="">
</div>
<div class="A4"><?php echo get_the_author_meta('aboute') ?></div>
</div>
Any helps ? Thanks.
Wordpress have pre defined variables, as
$cat
$tag
etc.
you have to use
$author
to make your process.
what you are doing wrong is you are not using your get_the_author_meta() function in side the loop so you need to specify the author id.
either use the function in side your loop or use simple as below code
<?php
global $current_user;
$current_user = wp_get_current_user();
$uid=$current_user->ID;
?>
change your function author meta as
<?php echo get_the_author_meta('first_name',$uid) ?>
for all your author meta for more help you can check reference code http://codex.wordpress.org/Function_Reference/get_the_author_meta
I am using the ACF purely so the user can upload images to a predefined location and have assigned the page rules accordingly. Everything seems to be fine on the WP back-end, with the three images uploaded to the fields. However, on the font end, nothing apart from blank box is appearing at all where the images should be. Looking at the source that WP is outputting, there is only blank code:
<img src="" class="middle" alt="image1"/>
This is the loop I am using:
<?php query_posts("posts_per_page=1&post_type=page&page_id=168"); if (have_posts()) :
while ( have_posts() ) :
the_post(); ?>
<!--If you want to refer to the child of parent page, use "post_parent=" -->
<li>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<img src="<?php the_field('image_1'); ?>" class="middle" alt="image1"/>
View More
</li>
<?php endwhile; ?>
<!-- post navigation -->
<?php else: ?>
<!-- no posts found -->
<?php endif; ?>
<?php wp_reset_query(); ?>
It is important to note that I am not pulling the images from another page. I just want the images to relate to the template & page I am working on.
Make sure the image field is outputting the id or url of the image link.
<?php if(get_field('YOUR FIELD NAME')): while(has_sub_field('YOUR FIELD NAME')): ?>
<img class="logo" src="<?php the_sub_field('image_1'); ?>" />
<?php endwhile; endif; ?>
I just needed to nominate the home page id the function:
<img src="<?php the_field('image_2', '245'); ?>" class="middle" alt="image2"/>
you can use get_the_field() to get the right value of the field,
<img src="<?php get_the_field('image_1'); ?>" class="middle" alt="image1"/>