Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to call the post ID in a script
<?php the_id() ?>
here :
$.get('', 'wpfpaction=add&postid=350');
I tried this but it's not working
$.get('', 'wpfpaction=add&postid='<?php the_id() ?>'');
Actually, my first goal was to do this action : wpfpaction=add&postid=350 which is usually in an url without load any url. Just to call the action.
Try using this instead:
<?php echo get_the_ID(); ?>
You don't need to change your javascript syntax to echo php variable into it.
$.get('', 'wpfpaction=add&postid=<?php the_ID() ?>');
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have this front-page.php page in my site and I want to put a block code directly in the php page. So I got a div and I want to put it in there. But the code is like
<!-- wp:latest-posts {"postsToShow":3,"displayPostContent":true,"excerptLength":30,"displayPostDate":true,"postLayout":"grid","displayFeaturedImage":true,"featuredImageSizeSlug":"large","align":"wide","className":"tw-mt-8 tw-img-ratio-3-2 tw-stretched-link is-style-default"} /-->
It's from a widget. I coudn't make it work please help :D
You can insert block code into any php template by using the function do_blocks() and passing in (valid) block content as a string, eg:
<?php
$block_content = '<!-- wp:latest-posts {"postsToShow":3,"displayPostContent":true,"excerptLength":30,"displayPostDate":true,"postLayout":"grid","displayFeaturedImage":true,"featuredImageSizeSlug":"large","align":"wide","className":"tw-mt-8 tw-img-ratio-3-2 tw-stretched-link is-style-default"} /-->';
echo do_blocks($block_content);
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am using the AdvancedCustomFields WordPress plugin, and I want to make a URL that comes out of this field, URL base64:
<?php echo get_post_meta($post->ID, 'author-link', true); ?>
The example link is: https://www.youtube.com/watch?v=u-oxmQxNBeQ
It should show on post: aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj11LW94bVF4TkJlUQ==
Simply encode the string with base64_encode() like below.
<?php echo base64_encode(get_post_meta($post->ID, 'author-link', true)); ?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have one div so i want to repeat the same div three time when the someone open the page.
If anyone knows please help me out
You want to use foreach (but this can only be used with PHP, and not HTML directly)
<?php for($i=0;$i<10;i++): ?>
<div>your code</div>
<?php endfor; ?>
this will repeat 10 divs for you. save as .php file
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Here is the code:
<?php if(function_exists('mk_slider')){mk_slider(427);} ?>
I need to put code
<?php the_field('slider_id'); ?>
instead of 427 in previous code, but it does not work, how shell i do it?
Help plz!
Try
<?php if(function_exists('mk_slider')){mk_slider(get_field('slider_id'));} ?>
^^^^^^^^^^^^^^^^^^^^^^
... and as a side note, now I need a shower. Dealing with wordpress code always leaves me feeling dirty/abused.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Currently I have:
Click here
This takes me to the index.php page
How do I change this in order to take me to another page?
Since you guys closed this. I will answer my own question:
The answer:
What you put in the WP_Query post_type = '(POST TYPE HERE)'
You can make a page called:
"single-(POST TYPE HERE).php
So once you click the link. This will take you to the:
"single-(POST TYPE HERE).php page
the_permalink() outputs the URL of the post currently being viewed in the loop. If you wanted to change the destination of the link then replace <?php the_permalink();?>.
Refs:
http://codex.wordpress.org/Function_Reference/the_permalink
http://codex.wordpress.org/The_Loop