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.
Related
I was curious if this would a best practice to add social media SVG icons to page and post types ( without using a plugin)?
I have added three custom fields to WordPress page and post. facebook, twitter and google plus fields I have added the WordPress provided SVG tags specific to each social media site.
wordpress page admin screenshot
here is the code that I have added to my front page where I need the social share icons to be added
<header class="entry-header-hp">
<div class="page-title-homepage">
<?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
<nav class="social-naviation-news" role="navigation">
<div>
<ul>
<li>
<a href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo urlencode(get_permalink()); ?>" target="_blank"><?php echo the_field('facebook'); ?>
</a>
</li>
<li>
<a href="https://twitter.com/intent/tweet?text=<?php echo urlencode(get_the_title()); ?>+<?php echo get_permalink(); ?>" target="_blank">
<?php echo the_field('twitter'); ?>
</a>
</li>
<li>
<a href="https://plus.google.com/share?url=<?php echo urlencode(get_permalink()); ?>" target="_blank">
<?php echo the_field('Google'); ?>
</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="entry-meta">
<?php echo the_modified_date(); ?>
</div><!-- .entry-meta -->
<div class="edit-link">
<?php twentyseventeen_edit_link( get_the_ID() ); ?>
</div>
</header><!-- .entry-header -->
As you can see the icons will display on the front page.
https//staging.rockimages.com
Is this a good approach or will this cause any problems down the line?
It wouldn't cause problem down the line but i recommend you structure the sharing element in a way that is re-usable and doesn't require bulk change on multiple pages templates. So basically make a function out of it and place it in your functions.php file of your theme. Also if you use any default Wordpress theme makes sure you copy the original and rename it or create a child theme.
Ref:
https://premium.wpmudev.org/blog/five-hacks-twenty-seventeen/#social
https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/
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">
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 have a custom page template with code:
<?php
/*
Template Name: Featured
*/
get_header(); ?>
<div id="content_box">
<div id="content" class="posts">
<img src="http://www.dinneralovestory.com/wp-content/uploads/2010/04/favorites.png" alt="Favourites"/><br clear="all" /><br />
<?php
//The Query
$my_query = new WP_Query('category_name=favourites');
if ($my_query -> have_posts()) :
?>
<?php while ($my_query -> have_posts()) : $my_query -> the_post(); ?>
<div class="featured_box">
<div class="featured_thumb">
<?php the_post_thumbnail(); ?>
</div>
<div class="featured_content">
<span class="post_title"><?php the_title(); ?></span>
<?php the_excerpt(); ?>
</div>
</div>
<br clear="all" /><br />
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/navigation.php'); ?>
<?php else : ?>
<h2 class="page_header center">Not Found</h2>
<div class="entry">
<p class="center">Sorry, but you are looking for something that isn't here.</p>
</div>
<?php
endif;
wp_reset_query();
?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
The navigation.php file has the previous / next code (it works fine for the standard post pages and archive pages)
navigation.php:
<?php if (is_single()) : ?>
<div class="navigation">
<span class="previous"><?php previous_post_link('← %link') ?></span>
<span class="next"><?php next_post_link('%link →') ?></span>
</div>
<div class="clear whitespace"></div>
<?php else : ?>
<div class="navigation">
<div class="previous"><?php next_posts_link('← Previous Entries') ?></div>
<div class="next"><?php previous_posts_link('Next Entries →') ?></div>
</div>
<div class="clear flat"></div>
<?php endif; ?>
I have set the maximum posts per page to 5, but the page using this theme template wont show the links. Any ideas? What code can i use to get them.
Thankyou
previous_post_link and next_post_link and the like don't make any sense for Pages. Pages are not ordered by date and time, they are hierarchical. In other words, there is no "next" Page. That doesn't make any sense in that respect.
Your base problem is that you're using a custom Page template to display Posts from a specific Category. This is the wrong way to do it, WordPress has perfectly valid category archives already, which work fine and which expect to display Posts properly.
Long story short: You will never get your Page Template approach to work 100% correctly. It just doesn't work that way. Posts were never meant to be displayed on Pages, and trying to do so only leads to things not working.
Below is the code I am using. I have tried everything I have been able to find and it still doesn't work. My permalink structure is /%category%/%postname%/. I believe that the url is correct that it is trying to go to i.e. http://localhost:8888/wordpress/blog/page/2. Annoyingly, the exact same code works on another site I have designed previously.
Could someone point me in the right direction please? Thanks
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=3&showposts=2&paged=" . $paged);
$wp_query->is_archive = true; $wp_query->is_home = false;
?>
<?php if (have_posts()) : ?>
<div id="lefttop"></div>
<div id="blogpoint">
<div id="leftcol">
<?php while (have_posts()) : the_post(); ?>
<div id="leftsquidge">
<h2><?php the_title(); ?></h2><br /><br />
<?php the_excerpt(); ?>
</div>
<div id="rightsquidge">
<?php the_tags( '<p><strong>File under:</strong> ', ', ', '</p>'); ?>
<?php the_time('F jS, Y') ?> by <strong><?php the_author() ?></strong>
</div>
<div style="clear:both;"></div>
<br /><br />
<?php endwhile; ?>
<div class="navigation" style="padding:0px;margin:0px;">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php endif; ?>
<div style="clear:both;"></div>
</div>
</div>
<div id="leftbot"></div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
EDIT
I have answered my own question. It was something I had tried before and wasn't working. You have to create a page, on the dashboard, that uses your category as the template.
Try going to "Reading Settings" in the Wordpress admin, and makes sure the "Blog pages show at most _ posts" is set to 2, or whatever your 'showposts' limit is in your query. Your query_posts is giving you accurate results but Wordpress is paging it based on your reading settings.
If the same code works fine in another site then check your settings for this site. Compare your permalinks settings on both the sites.
Does both the site work on the same environment (Apache or iis)?