Products
GG网络技术分享 2025-03-18 16:12 0
I have a Wordpress site and I\'m using the basic loop to bring in each Wordpress post
html
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
However I only want to bring in the title of each post as a link to that post (on its own single.php page) instead of all the content/images, etc. I have only been able to get all or nothing results.
By keeping your code, you can go this way.
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
echo \'<h2><a href=\\\"\'.get_the_permalink().\'\\\">\'.get_the_title().\'</a></h2>\';
//
} // end while
} // end if
?>
This way you\'ll get only your title with permalink. let me know if it helps you out or any thing else needed ?
###
hi you can give something like this
<?php if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
echo \'<a href=\\\"<?php the_permalink(); ?>\\\"><?php the_title(); ?></a>\';
//
} // end while
} // end if
?>
for further details you can refer this site
https://codex.wordpress.org/Function_Reference/the_permalinkDemand feedback