Can I use:
<?php
if (function_exists( 'wpp_get_mostpopular' )) {
wpp_get_mostpopular('range=weekly&order_by=views&limit=8');
}
?>
Inside custom template (inside query posts) to make query with own template output:
<?php query_posts(????????); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="myclass">
<?php echo get_the_post_thumbnail( $post_id, 'thumbnail'); ?>
</div>
Please help me with this, so I don't have to edit plugin and plugin's css while I have my ready just to query posts by this plugin.
Thanks.
Plugin: http://wordpress.org/plugins/wordpress-popular-posts/
#alen imeko as far as i have understoody your requirment, why you need this plugin, you just need to show the most popular post where ever you need to, You just need to set the post to sticky and call the sticky post using the same query post method then it will automatically render your specified post at the respective place.
For this just go to post to make it sticky, at the top above the publish/update button you will see an option visibility click the edit part of it and you will the options will slide down check the checkbox having text Stick this post to the front page and after that you just need to perform query.
$args = array(
'post__in' => get_option('sticky_posts'),
'posts_per_page' => 20,
'orderby' => 'title',
'post_date' => 'DESC',
'cat' => your category id
);
query_post($args);
?>
Then you need to simply use the while loop for that the same way you do in wordpress.
Related
A lot of articles here seem to deal with the "read more" link not displaying. Mine is displaying fine, it's just not actually taking us to a page that displays the full blog post. You can see how it's displaying here (Read More >>):
Right now when I click on "Read More >>" I get this:
In my code, in home.php, I'm displaying the blog posts like:
<?php
$paged = ( get_query_var('page') ) ? get_query_var('page') : '1';
$args = array('post_type' => 'post', 'posts_per_page' => 3, 'order' => 'ASC', 'orderby' => 'title', 'paged' => $paged);
$posts = new WP_Query($args);
if ($posts->have_posts()): while ($posts->have_posts()) : $posts->the_post();
get_template_part( 'content', get_post_format());
echo "<div class='thepost'><p class='post-date'>".get_the_date()."</p>";
echo "<h2 class='post-title'>".get_the_title()."</h2>";
//echo "<span class='post-image'>".the_post_thumbnail()."</span>";
the_post_thumbnail('post-thumbnail', ['class' => 'post-image']);
echo "<p class='post-paragraph'>".get_the_excerpt()."</p>";
echo "<p><span class='read-more'>Read More >></span></p> </div>";
endwhile;?>
So what do I need to change about this line: echo "<p><span class='read-more'>Read More >></span></p></div>"; so that it links to the complete post that the user clicks on?
I've looked through the codex on how to customize the read more link, but I'm just finding
"Users can then continue reading more as you have enticed them with your summary introduction, by clicking on a link to the full article. Themes usually include this link in the title and the above methods will generate it by default trailing your teaser."
I must be missing something as I'm reading through the codex. Thanks!
EDIT: Inspecting the link:
EDIT 2 Inspecting a broken page:
EDIT 3: full CSS (style.css): https://pastebin.com/TaUnemz9
EDIT 4 full screenshot for individual blog post page:
Three things first of all I can't told you exact what is problem without any proper link.but as i was going through closely of your screenshot.I found that
you get link like http://localhost/fourth-blog-post
When you click on read more button.
but it should be like this http://localhost/blog/fourth-blog-post
Because its single post of all your posts and its comes from single.php file,
now you can do two things first check url of your post via admin panel where your post is appear. second if it matches the second url which i mentioned on above link. then you should try the_permalink() function at the place of get_permalink() for more information you can visit.
https://codex.wordpress.org/Function_Reference/the_permalink
because get_permalink() should not be use with in loop. and it should be the_permalink() with in the loop.
I hope it will help you:)
First of all, the key was that single post pages display via single.php according to the WordPress Hierarchy.
So I needed to create a single.php file - most of the code for this file will still be the same as the code for home.php - it will still be displaying the header, the hero image, the nav menu, the footer, and the content will still be contained in a <div>.
What's different is that I need to take this out:
$paged = ( get_query_var('page') ) ? get_query_var('page') : '1';
$args = array('post_type' => 'post', 'posts_per_page' => 3, 'order' => 'ASC', 'orderby' => 'title', 'paged' => $paged);
$posts = new WP_Query($args);
And change the WordPress loop from this: if ($posts->have_posts()): while ($posts->have_posts()) : $posts->the_post(); to this: if (have_posts()): while (have_posts()) : the_post();. We already have the posts loaded, now we just need to display them.
Whatever WP functions I needed to get / echo changes depending on how displaying a single post is different from displaying multiple posts. I can take out:
get_template_part( 'content', get_post_format());
echo "<p class='post-paragraph'>".get_the_excerpt()."</p>";
echo "<p><span class='read-more'>Read More >></span></p> </div>";
Since I don't need them anymore.
The key is that links work differently in WordPress than basic HTML. It's not like in HTML where if you have Read More, you'll be taken to post-page.html when you click on Read More. Since it's a WP site, it's using PHP and you wrap the permalink in an <a> tag using the WP function .get_permalink().. Then the permalink will take you to single.php.
I am creating a custom WordPress Theme from scratch and I want to display some news from a certain category. I am doing it with the following code:
wp_reset_query(); $args = array(
'type' => 'post',
'posts_per_page' => 3,
'category_name' => 'oportunidades' );
$opp = new WP_Query($args);
while($opp->have_posts()) : $opp -> the_post(); ?>
<h4> <?php the_title(); ?></h4>
<?php endwhile; ?>
The list of news are being displayed correctly, but when I click the link to a certain post, it will change the URL of the page, but not display the contents of the post. If I echo the title, contents, and hyperlink of the post, it will echo the correct information.
How can I fix this, so when I click the post it shows the contents of the post?
*note: I have created a file named content.php, but it has no code inside. Can that be the problem?
I need to render all the posted "custom post type content" content from a "xx" user.
I have been trying to accomplish this, but of course, something is wrong.
that's why Im here, to learn how to make things right.
I have tried with this code: works. shows all the posts, but not from the author. How can I define wich author's post should be queried?
I can render the custom post types but I need to query only the author. Im making some sort of customized "archive" page.
<?php
query_posts(array(
'post_type' => 'video_listing',
'showposts' => 10
) );
?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>
You should be able to extend your query_posts() function call with the author or author_name parameter.
query_posts(array(
'post_type' => 'video_listing',
'author' => 1
'showposts' => 10
));
According to the example above 1 is the ID of the author you like to filter for.
i am beginner to WordPress, i have created the index.php it automatically shows my posts.. but i wanna posts to show also in another php file like blog.php.. how can i retrieve the same posts which is shown in index.php.........
The scenario is, i am developing theme for http://themeforest.net show that i wanna make some features in my blog page like without sidebar, left sidebar, right sidebar... but my home(index.php) contains posts.. whenever i starts new page with same coding(like blog.php), it doesn't show the index.php 's posts..
This sample piece of code retrieves 3 posts from categpry id 4
<?php
$args = array( 'numberposts' => 3, 'order'=> 'DESC', 'orderby' => 'post_date', 'category' => 4 );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);
$a= get_the_date();
?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<?php endforeach; ?>
Refer the WordPress documentation http://codex.wordpress.org/The_Loop
it contain different example how to display post include or exclude post from specific categories etc..
I'm having a hard time linking a menu built with custom fields to a page built the same way. I'm sure the problem is making it link via permalink, but for the life of me, I can't figure out what I'm missing.
<?php $loop = new WP_Query( array( 'post_type' => 'Employees', 'posts_per_page' => 100 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div>
<?php the_title(); ?><br />
<?php the_field('title'); ?>
Basically what I'm trying to do is on http://www.consociate.com/about/meet-the-team/, I want the links on the right to go to a template filled with custom fields (their bio information). Is this possible?
Thanks so much! I love this community!
What you are looking for can be achived by respecting the wordpress template hierarchy rules, you shouldn't hardcode links or hardcode add parameters to the links, simply use <?php get_template_part( $slug, $name ); ?> then create the resonse php file that will display the info as you want.