how to get page link of searched result in wordpress? - php

i tried this code in the read more button i want the link of page
<div class="blogleft">
<ul class="eachblog">
<?php while ( have_posts() ) : the_post(); ?>
<li>
<h1>
<?php the_title();?>
</h1>
<div class="perpostbg">
<?php $content = get_the_content(); echo substr($content,0,400); echo '...';?>
Read more
</div>
</li>
<?php endwhile;?>
</ul>
</div>

use permalink
Read more
OR
Read more

Just write
Read more
This code in your search loop

Related

Wordpress WP-PageNavi Not working with specific category post on homepage

I'm using the following code to display recent posts from a specific category on the homepage of my WordPress website.
<div class="frontleft">
<div id="four-columns" class="grid-container" style="display:block;">
<?php $catquery = new WP_Query( 'cat=3&posts_per_page=24' ); ?>
<ul class="rig columns-4">
<?php while($catquery->have_posts()) : $catquery->the_post(); ?>
<li>
<a href="<?php the_permalink() ?>">
<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
</a>
<h3>
<?php the_title(); ?>
</h3>
</li>
<?php endwhile; ?>
</ul>
</div>
<div class="navigation">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
<?php } ?>
</div>
</div>
Issue: WP-pageNavi plugin isn't working correctly.
Note: I'm able to open website.com/page/2 without having any issues. But the post list is precisely the same on each page.
How to fix it?
If I were you I would just use different Page Templates for homepage and other pages.
It's hard to debug a plugin that we aren't using.
There is a function in Wordpress is_page() where you can input the name of the page in the para. Throwing that in an if statement is also another way to separate the posts.
There are a ton of ways to achieve what your looking for without the use of a plugin.

How can I display data from custom post type marked as ‘featured post’ within a page template?

I am trying to achieve the following:
I have a custom post type called ‘album’. I am using the Featured Post plugin (https://wordpress.org/plugins/featured-post/) to select one of the albums. I want to display some data from that album in the sidebar of a page template.
At the moment the code I’m using is not returning anything:
<div class="left-column">
<?php query_posts(array('post_type' => 'album')); ?>
<?php query_posts($query_string . "&featured = yes"); ?>
<?php while (have_posts() ) : the_post(); ?>
<h3>Latest Release</h3>
<?php echo get_the_post_thumbnail($post->ID, 'post-thumbnail'); ?>
<div class="purchase">
<h3>Purchase now</h3>
<ul>
<li>
<a href="<?php the_field('itunes_link')?>" target="_blank">
<img src="http://localhost:8888/rezzonator/wp-content/uploads/2015/11/itunes.png">
</a>
</li>
<li>
<a href="<?php the_field('paypal_link')?>" target="_blank">
<img src="http://localhost:8888/rezzonator/wp-content/uploads/2015/11/paypal.png">
</a>
</li>
</ul>
</div>
<?php endwhile; ?>
</div>
Can somebody help? I’m fairly new to PHP coding…
Many thanks.
Fixed this by removing:
<?php query_posts($query_string . "&featured = yes"); ?>
Editing the first line:
<?php query_posts(array('post_type' => 'album', 'showposts' => 1)); ?>
And adding this at the end:
<?php wp_reset_query(); ?>

Getting the post title in index php in a while loop

I have
<?php while ( have_posts() ) : the_post(); ?>
<div class="boxes-third boxes-first">
<div class="latestthree">
<div class="title">
<?php get_the_title($id); ?> // I am trying to get the post title here but doesn't work
<span class="titlearrow"></span>
</div>
<div class="latestthreeimage">
<a rel="prettyPhoto" title="<?php get_the_title($id); ?>"> /same here
<?php the_post_thumbnail(array(300,133)); ?>
</a></div>
<div class="text">
Here i would like to get the excerpt of the post that is no longer than 25 words
<span class="textarrow"></span>
</div>
</div>
</div>
<?php endwhile; ?>
I am trying to do the above mentioned, but did not worked and on the last one did not find related info. I am using wp 3.7.1. Please help me.
You have used get_the_title() which does not print. To print out the title, add an extra echo:
<?php echo get_the_title(); ?>
Or you can use the_title(), which also prints:
<?php the_title();?>
Try just using,
the_title();
Reference.

Wordpress: Echo PHP depending on page ID

Good afternoon, I'm trying to display posts using PHP in the template, but I'm using the same template to output different posts depending on the age ID.
I currently have this code which works...
<?php //GET MEMBERS ?>
<?php query_posts('category_name=members&orderby=date'); ?>
<div class="row-fluid">
<ul class="thumbnails">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="span4">
<div class="thumbnail">
<?php // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
?>
<div class="pad">
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
But I need to output a different "category" depending on page ID... E.G
if page id is 7 echo "php script"
else page id is 13 echo "different php script"
Thanks, Brad
Wordpress has some built in functions. You can use get_the_ID() to return the ID number to use in your if statements.
Regards

Accordion Issue

I am setting up this site at games.nyls.edu. If you see when you click on any of the links on the 2nd column it opens up the first link. heres the code:
<?php query_posts('category_name=computable-diagrams&showposts=10'); ?>
<?php echo '<a onclick="changeCssClass(\'widget-title3\')" id="imageDivLink" href="javascript:toggle3(\'wp-cpl-widget3\', \'imageDivLink\');"><h3 id="widget-title3" class="widget-title">Computable Diagrams</h3></a> <ul id="wp-cpl-widget3" class="wp-cpl-widget" style="display: none;">'; while (have_posts()) : the_post(); ?>
<li class="wp-cpl wp-cpl-even"><a href="javascript:toggle9('testcontent3', 'imageDivLink6');">
<?php the_title(); ?>
</a> </li><div id="testcontent3" style="display:none;"><?php the_content();?></div>
<?php endwhile; ?>
</ul>
I would appreciate any help
<div id="testcontent3" style="display:none;">
this is inside loop ... will produce duplicate ids on the page ...you need to have unique id's for divs

Categories