Get next post's permalink in Wordpress - wordpress

I'm using this code to get a link to the next post in Wordpress
<?php next_post_link('%link', '', TRUE); ?>
And it gives me this result:
All I need is a URL like this:
http://www.someaddress.com/post/3/
Please help

Try:
Previous Post:
<?php echo get_permalink(get_adjacent_post(false,'',false)); ?>
Next Post:
<?php echo get_permalink(get_adjacent_post(false,'',true)); ?>

Related

Shortcode inside other shortcode Wordpress ACF

how to use this function correctly:
<?php echo do_shortcode('[product id="<?php the_field('wyrozniony_produkt_id')?>"]'); ?>
I need write inside this in place 3931
<?php echo do_shortcode('[product id="3931"]'); ?>
This shortcode (textfield from ACF)
<?php the_field('wyrozniony_produkt_id')?>
Anyone have idea how to make this?
your syntax seems to be wrong
please check the updated code of yours
<?php
$product_id = get_field('wyrozniony_produkt_id');
echo do_shortcode('[product id="'.$product_id.'"]');
?>

WordPress Permalink <?php the_permalink(); ?>

I am trying to grab a permalink for a page in WordPress and am using the following:
<?php the_permalink(); ?>
It works fine, but I need to strip something out of the output. It returns the following:
http://www.testing.com/es/patients/
Which is correct, but I want to strip out the "/es"
Is there a command I can add to this to strip out the /es and have it just say:
http://www.testing.com/patients/
You need to include those PHP lines on your page:
<?php
$url = the_permalink();
$final_url = str_replace("/es", "", $url);
echo $final_url;
?>
Then you can work in that edited variable $final_url

How to get page title in wordpress

Well, I have tried
<?php echo get_the_title('About Us');?>
But the code is not working. I am using wordpress 4.1. This should work but it isn't. Has wordpress updated the functions?
Try this one, It's may help you
<?php single_post_title(); ?>
Thanks :)
Try this one,may it's help you
<?php echo get_the_title(); ?>
And if you want to get page or post title By id
<?php echo get_the_title(post->$ID); ?>
Thanks
You are giving wrong parameters to get_title. See the codex.
You should have used ID instead to get the title.
So your code would be
<?php echo get_the_title(13); //where 13 is the ID of the about us page ?>
NOTE: Parameters are optional.
You could use the_title() to display the title of the page. You can pass parameters for before and after HTML tags. For morr information, here are the docs:
https://developer.wordpress.org/reference/functions/the_title/
<?php
the_title();
?>
You can try this
<?php echo get_page_by_title( 'About' ); ?>
Reference
<?php
$page = get_page_by_title( 'About Us' );
echo get_the_title($page->ID)
?>

How do I figure out if a record is a page or a post in wordpress

I am in search.php and I get, for a certain query, a set of results (pages and posts). Now, within the loop I am using to display such results, I need to figure out if the current item is actually a post or a page.
How do I do that? Is there a conditional tag to do it? I couldn't find it :(
Thanks
You can use is_page( $post->ID ) for pages and is_single( $post->ID ) for posts.
You can retrieve and check the post type of a post with get_post_type().
echo 'The post type is: ' . get_post_type( get_the_ID() );
The right answer is the following (sorry guys):
<?php while (have_posts()) : the_post(); ?>
<?php if ($post->post_type === "post"): ?>
it's a post!
<?php endif; ?>
<?php endwhile; ?>

Diamond MultiSite Widget

I am using Diamond MultiSite Widget in my site. Alongwith post title, url, description, I also want to display the post thumbnail. I have tried many times, contacted the plugin author for help but in vein. Does anyone know how to do it?
Ref: Please check 'Latest Questions' block in this quotation page.
Thanks.
First of all, you have to get the post id to belong that you get a post thumbnail image of that
Second, you have to display the post-featured Image.
Then this code is not working. please specify your actual requirement.
<?php $pages = get_pages(array('child_of' => 1)); ?>
<?php foreach ($pages as $page): ?>
<?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
<h1><?php echo $page->post_title; ?></h1>
<?php echo $page->post_content; ?>
<?php endforeach; ?>

Resources