You can see here what i am doing:
http://www.arvag.net/otkrijte-svet/leto/
So its pulling 2 custom fields from child pages, one of them is just url for the image on the left, and the other field is that text showing on the right.
Now, what i want to do is to add pagination there. The code i have now will just simply show all child pages, but i want to show only 5 child pages, so if user want to see 6th child page he would have to click on link for "Page 2" and so on.
The code im using to display these child pages is this:
<?php
$pages = get_pages('child_of='.$post->ID.'&sort_column=post_title&sort_order=desc');
$count = 0;
foreach($pages as $page)
{
$short_info = get_post_meta($page->ID,'info',true);
$image = get_post_meta($page->ID,'slika',true);
$count++;
?>
<div class='preview_slika left'><img src="<?php echo $image ?>" alt="<?php echo $page->post_title ?>" /></div>
<div class='preview_info right'>
<h2><?php echo $page->post_title ?></h2>
<p><?php echo $short_info ?></p>
Više o >>
</div>
<div class='clear'></div>
<?php
}
?>
So any idea what to do to get what i need?
Take a look at wp-PageNavi plugin. And this blog post if you want to integrate it in your theme an not have another plugin to manage.
Some guy posted some sample code on wordpress forums which works much better for me than this plugin.
http://wordpress.org/support/topic/383773
Related
How can I get avatar for authors who haven't post any content yet.
I have created a specific page for each author which shows the author s posts like a blog.
But for those with no post, WordPress display a default avatar instead of user s chosen profile picture.
here is my code for author`s info:
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<div class="nauthor-brief" style="">
<?php echo get_avatar( get_the_author_meta( 'ID' ) , 60 ); ?>
<div class="nauthor-brief-text">
<h2> <?php echo $curauth->display_name; ?></h2>
<p id="nauthor-description"><?php echo $curauth->user_description; ?></p>
</div>
</div>
Step 1: Log into your WordPress Dashboard
Step 2: In the left menu, under "Appearance", click "Editor"
Step 3: On the "Editor" page, find and click "content.php" in the list of files on the right of the page
Step 4: Find this section of code:
<div class="entry-meta">
<?php twentyeleven_posted_on(); ?>
</div><!-- .entry-meta -->
... and replace it with this:
<div class="entry-meta">
<? echo get_avatar( get_the_author_meta('user_email'), $size = '50'); ?>
That's it, you're done! In this tutorial we placed the author's avatar at the top of the post (for the homepage). If you'd like show the author's avatar from anywhere else within the post (or on other pages), simply use the following code:
<? echo get_avatar( get_the_author_meta('user_email'), $size = '50'); ?>
I installed a plugin called Admin Guide Dashboard Widget. The idea is that it adds a widget to the WordPress Control Panel (the first screen that shows up upon login). On this widget you choose a blog/post category and then every post you write with that category shows up in that widget.
Well it didn't work at all. The widget showed all of my posts. I tried to change the category on the widget, but I just couldn't get it to work so I uninstalled it. Then I realized the the_content() of all my blog posts was gone. I tried to install the plugin again, I tried to change the category I had set for the plugin, nothing worked. I uninstalled. The content part of my posts is still not showing up at all.
Before I installed that plugin I had only created one category, called "Nyheder"
Now I'm not sure if all of my posts were categorized as "Nyheder" or if they were simply uncategorized. I tried unchecking "Nyheder" from my posts but it gets checked again automatically. I don't know if my posts should be uncategorized (if that's even possible) or if the problem lies somewhere else.
The news archive page of the website in question is here. This page actually still shows the content. But if you click on a posts's title to go to its page, you will see that there is no content.
Here is the code on my single.php page, but I really doubt this is the problem.
<?php get_header(); ?>
<div id="pageHead">
</div>
<div id="main2" class="page clearfix">
<div id="content" class="threeFourth clearfix" style="width:100%;"><?php get_sidebar(); ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h1 style="display:inline;"><?php the_title(); ?></h1>
<?php
$page = $_SERVER['REQUEST_URI'];
if (substr($page, 1, 14) == "events_listing") {
echo "<h2>" . do_shortcode('[events-listing-date]');
if(do_shortcode('[events-listing-end-date]') != get_the_modified_date('d-m-Y') ) {
echo " til " . do_shortcode('[events-listing-end-date]') . "</h2>";
}
}
?>
<br>
<div class="meta clearfix" style="display:inline-block; padding-top: 10px; font-size: 14px;">
<?php _e('Skrevet af', 'themetrust'); ?> <?php the_author_posts_link(); ?> <?php _e('d.', 'themetrust'); ?> <?php the_time( 'j. F, Y' ) ?><br><br>
</div>
<?php edit_post_link(__('Edit Post', 'themetrust'), '<p>', '</p>'); ?>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div>
</div>
It looks like it had nothing to do with the plugin, but instead with another change I had made just before installing it. If you look at the code above, I defined a variable called $page. It turns out if I inserted the_content() before that it worked fine, but not after! So I changed the name of the variable to something else and put the_content() back in its place. Voila! I guess there was a conflict with the variable name $page and it somehow affected the_content().
I know that probably you have answered this questions many times but I can’t use your advices in my case.
I have the Adelle theme by Blu Chic on my blog (right now I just test different functions and make changes before I move my blog on my own hosting). I made same changes in archive.php to change how posts displays in categories and archive.
<div style="height:251px; display:block; margin:0 0 20px 0;"><h3><?php echo get_the_post_thumbnail( $post_id, array(174,251), array('class' => 'alignleft'), $attr ); ?> <?php the_title();?> </h3>
<?php the_excerpt(); ?></div>
I works but…during editing new post I have to set featured /thumbnail image. It’s not a problem. The problems show on first page because right now I have 2 images – one small and one big. Is it possible to remove thumbnail of post on main page?
I would be very grateful for your help!
Best,
Kasia
You simply need to find the CSS classes that belong to those thumbnail images on the main page and add a CSS property in the Additional CSS:
display: none
For screenshots you can check this guide: https://www.helpmegeek.com/remove-featured-thumbnails-list-pages-wordpress/
For your requirement to use two images for your post, one on the main page that is archive page and other on post detail page, you can use one best plugin available for that
http://wordpress.org/plugins/multiple-post-thumbnails/
By using Multiple Post Thumbnails plugin you can see two featured images for your post, one you can display on main page and other on post detail page or whichever section you want to display.
If you want to remove the thumbnails just delete/comment out the php code that display the thumbnail like so:
<div style="height:251px; display:block; margin:0 0 20px 0;">
<h3>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php //echo get_the_post_thumbnail( $post_id, array(174,251), array('class' => 'alignleft'), $attr ); ?> <!-- Notice the // just after the first <?php tag
</a>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php the_title();?>
</a>
</h3>
</div>
I want to display all pages in a one page design.
Now i have this code to do that:
<?php
$pages = get_pages($args);
//start loop
foreach ($pages as $page_data) {
$content = apply_filters('the_content', $page_data->post_content);
$title = $page_data->post_title;
$slug = $page_data->post_name;
?>
<!-- Content section -->
<div class="section" id="<?php echo "$slug" ?>">
<a name="<?php echo "$slug" ?>"></a>
<h2><?php echo "$title" ?></h2>
<?php echo "$content" ?>
</div>
<!-- END Content section -->
<?php } ?>
But now it show's also the empty parent pages. How can i exclude them? i found this on a website:
if($page->post_parent != 2){
But when I insert that into my code i only see the home section.
Is there also a way to apply different templates to the different pages? i know how it is normally done but with a one page website it is difficult.
Thnx
I'm guessing "empty pages" mean they don't have any content inside them.
Try to check if $content has anything inside of it, if not, don't display that page.
Put this inside your foreach statement right after $slug = $page_data->post_name; and before ?>
if($content == ""){
continue;
}
currently I am making a custom theme for my client and I am not a expert in this. My question is how to make different style for post from same category. Currently in my theme
Starting a New query for first post
<?php query_posts('showposts=1&cat=videos&offset=0'); if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<div class="first-news">
<h2><a href="<?php the_permalink() ?><?php the_title(); ?></a></h2>
<?php if( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail('video-thumb');?<?php} ?>
<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,8); ?>
</div>
<?php endwhile; else: endif; ?>
then again starting the same query for remaining 4 posts with another div and style
<?php query_posts('showposts=4&cat=videos&offset=1'); if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<div class="second-news">
<h3><a href="<?php the_permalink() ?><?php the_title(); ?></a></h3>
<?php if( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail('news-thumb'); ?><?php } ?>
<?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,8); ?>
</div>
<?php endwhile; else: endif; ?>
this working perfectly, Is this correct? I think there may be a good solution which will query post only once and get the required number of posts from same category with different style.
What I want is on below image.
You should use the category template from wordpress.
Before loading your page, wordpress looks for the presence of specific templates, example from the page linked above.
1. category-slug.php
2. category-ID.php
3. category.php
4. archive.php
5. index.php
In order to activate “post formats” in WordPress 3.1+, you will need to open your theme’s functions.php file and paste the following code:
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
Note: aside, and gallery are not the only available post formats. The available list of post formats are:
aside – Typically styled blog format.
chat – A chat transcript.
gallery – A gallery of images.
link – A link to another site.
image – A single image.
quote – A quotation.
status – A short status update, usually limited to 140 characters. Similar to a Twitter status update.
video – A single video.
For the full list of post formats, refer to WordPress Codex.
Once you have added this code, you will see a new field in your post write panel in the right hand column where you see publish.
Upon writing the post, you can change the format and hit publish. This will allow you to display your post in a pre-styled format.
Edit your post loop.
Suppose in your case videos category post format is video
We are going to be utilizing the conditional tag: has_post_format()
if ( has_post_format( 'video' ) {
// Blog Category format
}
else
{
// Normal Formate
}
I hope this will help you. More Info...