code pasting not working
-
Hi there,
I’m a CSS beginner who’s having trouble finding which bit to paste in the code to the loop.
I’ve looked at the WP Codex and have pasted in the code to the index.php within the loop. Plugin is activated and the featured image has a caption in the meta box.website is http://www.revolutionaryhabit.com
Still nothing shows up. Any ideas?
All help appreciated,
S
-
Can you post to pastebin the contents of the file where you pasted the plugin’s theme function?
I noticed op did not reply but for those interested, you do not even need to place the code on your theme.
I do not like advertising other plugins, but this two go together like peanut butter and jelly, or cookies and cream or bacon cheeseburger with peanut butter (if you are from that cult).Anyways, plugin: Post Snippets by Johan Steen.
Once you have said plugin, got to its settings page, “Add New Snippet”, set a title for it (no spaces), check to enable Shortcode and PHP Code and add something like this on the Snippet window (modify as needed to fit your needs):
echo "<p><i>Featured Image Credit: </i></p>"; cc_featured_image_caption(); echo "<hr />";This will create a snippet that can be inserted onto your posts right from the editor with the featured image caption included.
@avluis that did the trick – thanks!
I really like this plugin so far, and still would like to get it to work without using the Post Snippets plugin (though together, they did work nicely). I’m really frustrated that I’m not getting the installation correct.
I’m using the Twenty Fifteen theme. I’ve tried adding
<?php cc_featured_image_caption(); ?>to index.php (in several places; I should be back to the original index file now).I have deactivated the Post Snippets plugin although the shortcode is still visible on two posts. Yo, don’t judge the content. This is my kid’s site.
Can you show me what I’m missing? Thanks much!
You don’t really want to put it in
index.phpbut in the appropriatecontent-[posttype].phpfile. Better yet, you should create a child theme and modify the files where you’d like to use the code.I am planning to modify the way the plugin inserts the caption data in the theme so that no code changes will be required. Hopefully I’ll have that taken care of soon.
First of all, I want to thank you for responding so quickly!
Also, I appreciate the reminder re child theme. I was so hot to solve this puzzle it had totally slipped my mind.(1) So you’re saying I need to create a custom post template?
My confusion (still) lies in placing your one line of code. Even if I create a CPT (in which I would be modifying index.php or single.php as for use in my child theme (?) I’m not sure; I’ve been working on that today. unsuccessfully.) (2) adding that line of code “within the loop” (ex: lines 31-39 of parent/index.php) would break the
<?php ... ?>of lines 30-53?I have tried placing your code in every rational place between the get_header & get_footer with no luck.
I appologize if this question is too basic. I’m new to the dark arts of WP. Thanks for your time.
and thanks for putting this on your to-do list!
If you are using the theme Twenty Fifteen then that tells me you have the latest WordPress – which means that your WordPress install will contain different type of content pages where you could insert
<?php cc_featured_image_caption(); ?>.If you want to minimize the number of plugins WordPress is using, while taking advantage of this plugin – at least while the developer takes care of this automatically in a future update – you will need to make use of child themes.
If you have never created a child theme, there is a plugin that lets you create one based on your current theme. You then switch to your child theme and you are free to uninstall that plugin.
From there, I recommend reading up on functions.php and how to filter content so you can add<?php cc_featured_image_caption(); ?>dynamically.
If you don’t care too much about that, then you can simply modify your child theme – look for php files that start withcontentinwp-content > themes > your child theme.
If you open any of those content files, the first few lines, which are comments, will tell you what they do. So essentially, it all depends where you want your<?php cc_featured_image_caption(); ?>to be displayed.
Good luck, and have fun learning more about the inner workings of WordPress.Worked for me Alihaag. I’m using a child of twentyfifteen.
After this (in content.php):
<header class="entry-header">I added this:
<?php cc_featured_image_caption(); ?>Hi ,
I installed the plugin and set the code with posts snippets ( as avluis told).
It works now in this way, that when I right click on the image, I got the appropriate information in grafik info.But is it possible to show the information directly below or on the image all the time?
Thanks a lot in advance,
MichiI’ve released version 0.5.0 which supports automatic caption insertion. This should take care of what you’re looking to do with it.
Hello Christiaan,
sorry for late response. Works great now. Thanks a lot for your efforts and spend time. Thanks!Awesome! Thanks for the update.
Hi Christian, I just found your plugin and it looks like it perfectly fits what I was looking for, but for some reason it won’t activate …?? I’ve deleted it and re-uploaded it to my plugins folder 3 times. Any suggestions?
Thanks 🙂
Daphne,
Would you mind creating a new thread for your issue? That way we can keep different issues separate. Thanks!
The topic ‘code pasting not working’ is closed to new replies.