I need to add a menu on a wordpress page but on the tinymce editor. I know there are a couple of tags ["example"=something] for plugins so I would like to know if there's anything similar to load a menu.
this is how I'm loading the menu on the editor (php)
<?php wp_nav_menu( $args ); ?>
and what I need is to load the menu between content that is editable for a specific page.
I am not sure what is your exact requirement. If you need a button on your editor you can use the below code to your themes functions.php. This code will add a button tag creator to the editor. Similarly you can add anything in the editor.
<?php
// Add buttons to html editor
add_action('admin_print_footer_scripts','eg_quicktags');
function eg_quicktags() {
?>
<script type="text/javascript" charset="utf-8">
button = edButtons.length;
edButtons[edButtons.length] = new edButton('ed_paragraph','button','<button>','</button>','button');
jQuery(document).ready(function($){
jQuery("#ed_toolbar").append('<input type="button" value="p" id="ed_paragraph" class="ed_button" onclick="edInsertTag(edCanvas, button);" title="p" />');
});
</script>
<?php
}
?>
First off, as the other answer suggests, you're likely going about this the wrong way. BUT : to solve your problem, wordpress provides a custom menu widget, and there is a plugin to put any widget you like on any page vai the editor, using a shortcode.
Have a look at this:
https://wordpress.org/plugins/widget-shortcode/
Related
I have a menu that is used throughout the entire site (pages and posts). I would like to change the link of one single menu item (custom link) if the menu is displayed on on a blog post.
I tried using the plugin Conditional Menus which could do the job, but has the disadvantage that I would need to recreate the entire menu for each language and repeat this everytime the menu is updated.
I think it would be smarter to do this through php. I found this to check post vs. page:
<?php
if(get_post_type() === 'post') {
// Do something
}
?>
Would it be possible to set the href of the <a> tag in menu-item-123 within this if-statement? Also, is there a way I can add this to functions.php in the child theme or does it need to placed somewhere else? Thanks!
Please write following codes in your functions.php file Here ".primary-menu" WILL BE the css class of your menu UL, I've setup 3rd child in the menu item, you can change it accordingly.
<?php
add_action( 'wp_footer', 'change_link' );
function change_link(){
if(get_post_type() === 'post') { ?>
<script>
(function($) {
jQuery('.primary-menu li:nth-child(3) a').attr("href", "https://google.com");
})(jQuery);
</script>
<?php }
}
I'm making a WordPress theme by myself since I'm working for the first time in Wordpress I've watched some tutorials about it.
I have page.php header and footer and ofc an index. I insert the content from the pages with this:
<?php echo get_post_field('post_content', $post->ID); ?>
but I tried the get_post in a while loop with same result..
Everything is fine but when I want to use a plugin I can't add to my page... When I insert the shortcode of it it shows only the shortcode string... There are some plugins where I can click a "view" option and it would show a page with my plugin (for example a calendar) but that page is empty...
When I activate an original theme it works instantly... So I'm sure something is missing from my theme something which can load the plugins but I couldn't find solution for it.
Any ideas?
Did you add the <?php wp_head(); ?> function before the head area of the html document is closing? It imports important scripts and styles from wordpress itself (and probably also from the plugins).
See here:
https://developer.wordpress.org/reference/functions/wp_head/
Before closing the body area, the template should also include
<?php wp_footer();?>
See here:
https://developer.wordpress.org/reference/functions/wp_footer/
I add shortcode in such way:
add_shortcode( 'NAME', array( $shortcode, 'add_shortcode' ) );
add_filter( 'widget_text', 'do_shortcode' );
This shortcode display html form with filters.
This shortcode I use(add) in widjet, but the result of this form I want to display on content page.
So I click submit the form and the result displays on content page.
How can I do this in best way?
I will be glad of any help.
This may be a bit difficult to do in a eloquent manner. The reason is that most WP templates generate the content before they generate the widgets - in the majority of templates the content is generated in files like content-page.php and the widgets are generated from files like sidebar.php.
Your best bet is to use some jQuery to inject HTML after the fact. For example, in the content you can generate an empty tag like this:
<div id="post-load"></div>
and then have your widget call something like this:
<script>
$( document ).ready(function() {
$("#post-load").html('your html goes here');
});
</script>
I know this does not answer your question more completely, but it's difficult to assume what your starting point is.
I have a wordpress blog and I want to customize it a bit. I know CSS and HTML but not php. from what I understood the php should call the html code, so if i could find the html code it will be easy for me to customize my blog.
The thing is, I can't find the html code. I looked at appearance --> editor and it is all php files and one css.
Someone has an idea how to edit the html code/find it ?
thanks
If you want to edit your wordpress theme html , css etc. Kindly follow the steps.
Always use a child theme
Before you start editing your WordPress theme create a child theme. Child themes are important, because they protect your original theme files.
Appearance → Themes->your child theme-> activate
Edit WordPress theme HTML
Go to Appearance → Editor in your WordPress dashboard and choose the child theme you have activated.
There are index.php, functions.php, header.php, footer.php etc.
In its most basic form, PHP is grabbing content from your WordPress site and outputting it in an HTML page. Take a look at this section of code specifically:
<div class="site-info">
<?php do_action( 'twentyfourteen_credits' ); ?>
<?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?>
</div><!-- .site-info -->
That code translates to this HTML:
<div class="site-info">
Proudly powered by WordPress
</div><!-- .site-info -->
Try to understand like the above codes php and html. you can easily edit it.
Edit WordPress theme CSS
Appearance → Editor->style.css(child theme).
you can change the style of detailed reference click here
Go to your wp-admin, Appearance (on the left sidebar), Editor. Select a theme and a file to edit, then press Save.
In WordPress Dashboard > Appeareance > Editor you can't edit HTML files (only PHP and CSS files) as you can read in Codex - "Editing files"
Your question could become why don't you see HTML in PHP files?
This is because PHP generates HTML code and then you can see lots of PHP code inside a PHP file, but not necessarly HTML code. In order to understand how PHP works I suggest you to read this useful tutorial.
I have a RocketTheme Affinity template that when it hides the component the wrapper stays untouched and i want it removed also.
I only want to disable it from the home page (id=101).
In the "index.php" the bellow code calls this:
<?php
echo $section_rows->render();
?>
The div name is "section-row3" in a file called "rt_sectionrows.php"
There are also css files called style6 and tempate.css files.
Conclusion:
How do I hide certain div and class from homepage?
Try this,
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
?>
<script type="text/javascript">jQuery(document).ready(function(){
jQuery('.section-row3').hide()
});</script>
<?php
}
?>
Add this code at the bottom of your home page. It hide that div.
Hope it helps.
You should be able to just do this with some CSS.
Go into the Joomla! Administrator, Menus, Select the menu which contains your homepage menu item and then edit it.
In the menu item, select 'Page Display'. At the bottom you will see: Page Class.
Add a space and type: homep
Then add:
.homep .section-row3 {display: none !important;}
To your Rocket Theme Custom CSS or LESS file.
Then that will just hide it with CSS, we have specified !important, so it takes priority.