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
Related
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.'"]');
?>
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)
?>
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)); ?>
I am using the shortcode in the loop inside template file
and also using the lightbox form plugin.
<?php query_posts('showposts=9&post_type=packages') ?>
<?php while (have_posts()) :the_post(); ?>
<?php echo the_post_thumbnail(); ?>
...
...
<?php echo do_shortcode("[formlightbox text='Book Now' title=the_title][contact-form-7 id='383' title='Booking Form'][/formlightbox]"); ?>
<?php endwhile; ?>
Please note that in the shorcode there is title=the_title and it is not appened to the anchor tag.
But when I use title='hello'or something else it gets appended to the anchor tag.
I want current post's title should get appened to the rendered anchor tag via shortcode.
please help me
Break the string and use the string concatenation operator to combine the function into your string.
<?php echo do_shortcode("[formlightbox text='Book Now' title='" . get_the_title() . "'][contact-form-7 id='383' title='Booking Form'][/formlightbox]"); ?>
Update
This should use the get_the_title() as opposed to the_title() which echos the title.
I have a page with template No Sidebars I want to list 5 posts' titles on that page by author where the author's name = page's title
any idea how to do so without using any plugin?
I thought that query_posts function would do the trick but this important note kind of tells me that I cannot use query_posts
Here's a bit of code that will probably get you the Post Titles by author; in order to have this automatically feed off of the page title I'd have your title generation code... Hope this helps you get at least part of the way there...
<?php $my_query = new WP_Query('author_name=YourAuthor&showposts=5'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
<?php the_title(); ?></a><?php endwhile; ?>
Check out Function Reference/WP Query « WordPress Codex and an earlier answer (with the same code :) as poindexter's) at Wordpress display featured posts outside of loop